|
xxx
ASP:XML Control by Charles Carroll
This page demonstrates how to use
the ASP:XML control a convenient tool to transform XML with style sheets and
such. Note that the <asp:xml> server control has four properties:
-
DocumentSource
(filepath to XML data file)
-
TransformSource
(filepath to XSL/T transform file)
-
Document
(reference to an XmlDocument object), and
-
Transform
(reference to an XslTransform object).
You
can programmatically manipulate any of them by giving the control a
"id" (just like any other server control). Documentation is at:
http://docs.aspng.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/xml/doc_xml.aspx
Here is a sample of it
combining an XML file with a XLST transformation:
filename=/experiments/xmlcontrol/mb.xml
<?xml version="1.0"?>
<questionairre type="MB">
<item>
<question>At a party do you</question>
<answer code="E">interact with many, including strangers</answer>
<answer code="I">interact with a few, known to you</answer>
</item>
<item>
<question>Are you more</question>
<answer code="S">realistic than speculative</answer>
<answer code="N">speculative than realistic</answer>
</item>
<item>
<question>It is worse to</question>
<answer code="S">have your "head in the clouds"</answer>
<answer code="N">be "in a rut"</answer>
</item>
<item>
<question>Are you more impressed by</question>
<answer code="T">principles</answer>
<answer code="F">emotions</answer>
</item>
<item>
<question>Are you more drawn toward the</question>
<answer code="T">convincing</answer>
<answer code="F">touching</answer>
</item>
<item>
<question>Do you prefer to work</question>
<answer code="J">to deadlines</answer>
<answer code="P">just "whatever"</answer>
</item>
<item>
<question>Do you tend to choose</question>
<answer code="J">rather carefully</answer>
<answer code="P">somewhat impulsively</answer>
</item>
<item>
<question>At parties do you</question>
<answer code="E">stay late, with increasing energy</answer>
<answer code="I">leave early, with decreased energy</answer>
</item>
<item>
<question>Are you more attracted to</question>
<answer code="S">sensible people</answer>
<answer code="N">imaginative people</answer>
</item>
<item>
<question>Are you more interested in</question>
<answer code="S">what is actual</answer>
<answer code="N">what is possible</answer>
</item>
<item>
<question>In judging others are you more swayed by</question>
<answer code="T">laws than circumstances</answer>
<answer code="F">circumstances than laws</answer>
</item>
<item>
<question>In approaching others is your inclination to be</question>
<answer code="T">objective</answer>
<answer code="F">personal</answer>
</item>
<item>
<question>Are you more</question>
<answer code="J">punctual</answer>
<answer code="P">leisurely</answer>
</item>
<item>
<question>Does it bother you more having things</question>
<answer code="J">incomplete</answer>
<answer code="P">completed</answer>
</item>
<item>
<question>In your social groups do you</question>
<answer code="E">keep abreast of other's happenings</answer>
<answer code="I">get behind on the news</answer>
</item>
<item>
<question>In doing ordinary things are your more likely to</question>
<answer code="S">do it the usual way</answer>
<answer code="N">do it your own way</answer>
</item>
<item>
<question>Writers should</question>
<answer code="S">say what they mean and mean what they say</answer>
<answer code="N">express things more by use of analogy</answer>
</item>
<item>
<question>Which appeals to you more</question>
<answer code="T">consistency of thought</answer>
<answer code="F">harmonious human relationships</answer>
</item>
<item>
<question>Are you more comfortable in making</question>
<answer code="T">logical judgments</answer>
<answer code="F">value judgmants</answer>
</item>
<item>
<question>Do you want things</question>
<answer code="J">settled and decided</answer>
<answer code="P">unsettled and undecided</answer>
</item>
<item>
<question>Would you say you are more</question>
<answer code="J">serious and determined</answer>
<answer code="P">easy-going</answer>
</item>
<item>
<question>In phoning do you</question>
<answer code="E">rarely question that it will all be said</answer>
<answer code="I">rehearse what you'll say</answer>
</item>
<item>
<question>Facts</question>
<answer code="S">speak for themselves</answer>
<answer code="N">illustrate principles</answer>
</item>
<item>
<question>Are visionaries</question>
<answer code="S">somewhat annoying</answer>
<answer code="N">rather fascinating</answer>
</item>
<item>
<question>Are you more often</question>
<answer code="T">a cool-headed person</answer>
<answer code="F">a warm-hearted person</answer>
</item>
<item>
<question>Is it worse to be</question>
<answer code="T">unjust</answer>
<answer code="F">merciless</answer>
</item>
<item>
<question>Should one usually let events occur</question>
<answer code="J">by careful selection and choice</answer>
<answer code="P">randomly and by chance</answer>
</item>
<item>
<question>Do you feel better about</question>
<answer code="J">having purchased</answer>
<answer code="P">having the option to buy</answer>
</item>
<item>
<question>In company do you</question>
<answer code="E">initiate conversation</answer>
<answer code="I">wait to be approached</answer>
</item>
<item>
<question>Common sense is</question>
<answer code="S">rarely questionable</answer>
<answer code="N">frequently questionable</answer>
</item>
<item>
<question>Children often do not</question>
<answer code="S">make themselves useful enough</answer>
<answer code="N">exercise their fantasy enough</answer>
</item>
<item>
<question>In making decisions do you feel more comfortable with</question>
<answer code="T">standards</answer>
<answer code="F">feelings</answer>
</item>
<item>
<question>Are you more</question>
<answer code="T">firm than gentle</answer>
<answer code="F">gentle than firm</answer>
</item>
<item>
<question>Which is more admirable</question>
<answer code="J">the ability to organize and be methodical</answer>
<answer code="P">the ability to adapt and make do</answer>
</item>
<item>
<question>Do you put more value on the</question>
<answer code="J">definite</answer>
<answer code="P">open-ended</answer>
</item>
<item>
<question>Does new and non routine interaction with others</question>
<answer code="E">stimulate and energize you</answer>
<answer code="I">tax your reserves</answer>
</item>
<item>
<question>Are you more frequently</question>
<answer code="S">a practical sort of person</answer>
<answer code="N">a fanciful sort of person</answer>
</item>
<item>
<question>Are you more likely to</question>
<answer code="S">see how others are useful</answer>
<answer code="N">see how others see</answer>
</item>
<item>
<question>Which is more satisfying</question>
<answer code="T">to discuss an issue thoroughly</answer>
<answer code="F">to arrive at agreement on an issue</answer>
</item>
<item>
<question>Which rules you more</question>
<answer code="T">your head</answer>
<answer code="F">your heart</answer>
</item>
<item>
<question>Are you more comfortable with work that is</question>
<answer code="J">contracted</answer>
<answer code="P">done on a casual basis</answer>
</item>
<item>
<question>Do you tend to look for</question>
<answer code="J">the orderly</answer>
<answer code="P">whatever turns up</answer>
</item>
<item>
<question>Do you prefer</question>
<answer code="E">many friends with brief contact</answer>
<answer code="I">a few friends with more lengthy contact</answer>
</item>
<item>
<question>Do you go more by</question>
<answer code="S">facts</answer>
<answer code="N">principles</answer>
</item>
<item>
<question>Are you more interested in</question>
<answer code="S">production and distribution</answer>
<answer code="N">design and research</answer>
</item>
<item>
<question>Which is more of a compliment</question>
<answer code="T">There is a very logical person.</answer>
<answer code="F">There is a very sentimental person.</answer>
</item>
<item>
<question>Do you value in yourself more that you are</question>
<answer code="T">unwavering</answer>
<answer code="F">devoted</answer>
</item>
<item>
<question>Do you more often prefer the</question>
<answer code="J">final and unalterable statement</answer>
<answer code="P">tentative and preliminary statement</answer>
</item>
<item>
<question>Are you more comfortable</question>
<answer code="J">after a decision</answer>
<answer code="P">before a decision</answer>
</item>
<item>
<question>Do you</question>
<answer code="E">speak easily and length with strangers</answer>
<answer code="I">find little to say to strangers</answer>
</item>
<item>
<question>Are you more likely to trust your</question>
<answer code="S">experience</answer>
<answer code="N">hunch</answer>
</item>
<item>
<question>Do you feel</question>
<answer code="S">more practical than ingenious</answer>
<answer code="N">more ingenious than practical</answer>
</item>
<item>
<question>Which person is more to be complimented</question>
<answer code="T">one of clear reason</answer>
<answer code="F">strong feeling</answer>
</item>
<item>
<question>Are you inclined more to be</question>
<answer code="T">fair minded</answer>
<answer code="F">sysmpathetic</answer>
</item>
<item>
<question>Is it preferable mostly to</question>
<answer code="J">make sure things are arranged</answer>
<answer code="P">just let things happen</answer>
</item>
<item>
<question>In relationships should most things to</question>
<answer code="J">renegotiable</answer>
<answer code="P">random and circumstantial</answer>
</item>
<item>
<question>When the phone rings do you</question>
<answer code="E">hasten to get to it first</answer>
<answer code="I">hope someone else will answer</answer>
</item>
<item>
<question>Do you prize more in yourself</question>
<answer code="S">a strong sense of reality</answer>
<answer code="N">a vivid imagination</answer>
</item>
<item>
<question>Are you drawn more to</question>
<answer code="S">fundamentals</answer>
<answer code="N">overtones</answer>
</item>
<item>
<question>Which seems the greater error</question>
<answer code="T">to be too passionate</answer>
<answer code="F">to be too objective</answer>
</item>
<item>
<question>Do you see yourself as basically</question>
<answer code="J">the structured and scheduled</answer>
<answer code="P">the unstructured and unscheduled</answer>
</item>
<item>
<question>Are you a person that is more</question>
<answer code="J">routinized than whimsical</answer>
<answer code="P">whimsical than routinized</answer>
</item>
<item>
<question>Are you inclined to be</question>
<answer code="E">easy to approach</answer>
<answer code="I">somewhat reserved</answer>
</item>
<item>
<question>In writings do you prefer</question>
<answer code="S">the more literal</answer>
<answer code="N">the more figurative</answer>
</item>
<item>
<question>Is it harder for you to</question>
<answer code="S">identify with others</answer>
<answer code="N">utilize others</answer>
</item>
<item>
<question>Which do you wish more for yourself</question>
<answer code="T">clarity of reason</answer>
<answer code="F">strength of compassion</answer>
</item>
<item>
<question>Which is the greater fault</question>
<answer code="T">being indiscriminate</answer>
<answer code="F">being critical</answer>
</item>
<item>
<question>Do you prefer the</question>
<answer code="E">planned event</answer>
<answer code="I">unplanned event</answer>
</item>
<item>
<question>Do you tend to be more</question>
<answer code="J">deliberate than spontaneous</answer>
<answer code="P">spontaneous than deliberate</answer>
</item>
</questionairre>
Here is the MB.xml file:
filename=/experiments/xmlcontrol/mb.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"
omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:for-each select="/questionairre/item">
<xsl:variable name="Pos" select="position()" />
<xsl:variable name="Num" select="concat('Q',$Pos)" />
<p><xsl:value-of select="concat($Pos,'. ', question)" />
—<br /><br />
<input type="radio" name="{$Num}" value="U"
checked="checked" />Undecided<br />
<xsl:for-each select="answer">
<input type="radio" name="{$Num}" value="{@code}" />
<xsl:value-of select="." /><br />
</xsl:for-each>
</p>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Here is the MB.xsl file:
filename=/experiments/xmlcontrol/xmlcontrol.aspx
<%@ trace="true"%>
<html><head>
<title>XML Control Sample</title></head>
<body bgcolor="#FFFFF">
<asp:xml id="Xml1" DocumentSource="mb.xml" TransformSource="mb.xsl" runat=server/>
</body></html>
|