[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Getting variable yet most immediate parentNode

Subject: Re: Getting variable yet most immediate parentNode
From: Steve <subsume@xxxxxxxxx>
Date: Fri, 28 Sep 2007 11:26:30 -0400
Re:  Getting variable yet most immediate parentNode
>Abel Braaksma <abel.online@xxxxxxxxx> wrote:
> which means that <xsl:template match="option" mode="q">... will never be
> triggered by this snippet:
>
>     <xsl:template match="questions">
>         <xsl:apply-templates mode="q" select="option" />
>         <SNIP />
>     </xsl:template>

Yep, that's my fault. Questions do have option children. My mistake.

> Steve, if you rewrite statements like that as this one above as:
>
>     <xsl:template match="answers[option]">
>        ....

Ahh, yes. Wise and simple, thank you. Done.

>
> Wendell, considering the possible intent of Steve to wrap all output
> inside one <div>, it is probably better if he does go back to using the
> // syntax, but not in the way I proposed, but more like this (assuming

I think we've gone awry. .//answer's doesn't make sense because, as
Wendell pointed out, I want to go up the tree if there is no child
<answers />. I tried his syntax, however I'm not sure how to make it
choose a child answer's node before it goes looking for the closest
ancestral answer node (without using those pesky case statements).


> <xsl:template match="option">
>     <option><xsl:value-of select="(@name | .)[1]" />
> </xsl:template>

And finally, this last shortcut doesn't function. My logic is "If it
has a @name, use it, otherwise just use the node's text." I'm honestly
not sure how to interpret this shortcut because the "|" seems to imply
union, which of course doesn't seem to fit my intentions. At any rate,
this statement never spits out question <option>s with @name.

I'm assuming much of the confusion over what I am attempting is my
fault, and particularly my pasting a slightly incomplete source XML.
Here is an actual example.

<root>
		<section key="D" name="Nutritional status">
			<questions>
				<option key="A" name="Does client have prescribed diet by physician?" />
				<option key="C" name="Do you have a good appetite?" />
				<option key="K" name="Daily fluid intake per cups?">
					<answers>
						<option p="1">1</option>
						<option p="2">2</option>
						<option p="3">3</option>
						<option p="4">4</option>
						<option p="5">5</option>
					</answers>
				</option>
				<option key="J" name="Weight">
					<answers>
						<option p="1">Underweight</option>
						<option p="2">Overweight</option>
						<option p="0">Normal</option>
					</answers>
				</option>
				<option key="L" name="Taking vitamin/mineral supplements?" />
			</questions>
			<questions>
				<answers>
					<option p="1">5</option>
					<option p="2">1</option>
					<option p="3">1.5</option>
					<option p="4">2</option>
					<option p="5">3</option>
					<option p="6">4 or more</option>
				</answers>
				<option key="D" value="POULTRY">Servings of meat, fish, eggs,
dried peas, beans and nuts</option>
				<option key="E" value="FRUIT">Servings of citrus fruit, juices and
tomatoes</option>
				<option key="F" value="GREENVEG">Servings of dark green, leafy
vegetables</option>
				<option key="G" value="VEG">Servings of other fruits, vegetables
and juices</option>
				<option key="H" value="STARCH">Servings of bread, cerea, rice,
pasta</option>
				<option key="I" value="DAIRY">Servings of dairy products</option>
				<option key="J" value="MISC">Servings of Misc. foods</option>
			</questions>
		</section>
</root>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.