Your description is very light on details and of a general nature, so in a
general way, yes, it makes sense. On the other hand, I sense that you want
specific advice which is impossible to give based on a general question.
The "best practice" approach to writing XSLT is to "apply-templates" at a point
high in the document tree, usually something like this:
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
Then for each element you want to match, you write a template to output what
you want as I illustrated in my replay. For those elements you wish to ignore,
you write a template that outputs nothing, e.g. <xsl:template
match="some-element-name-you-wish-to-ignore" />.
It may be helpful, if structure of your document permits, to write a single
template to match an element such as your <Answer> element and put an
<xsl:choose> element to discriminate between possible values. For example,
instead of writing two templates as I did in my original answer, I might have
done this:
<xsl:template match="Answer">
<xsl:choose>
<xsl:when test="@name='Female' and TFValue='false'">
<!-- your output goes here -->
</xsl:when>
<xsl:when test="@name='ticdesc'">
<xsl:value-of select="TextValue" />
</xsl:when>
<xsl:when test="another test goes here'">
<!-- your output goes here -->
</xsl:when>
<xsl:otherwise>
<!-- your default output goes here -->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
but that is a little harder to understand, so I simplified it by making two
templates.
More specific advice is not possible without a more specific question.
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
-----Original Message-----
From: Julian Voelcker <asp(_at_)tvw(_dot_)net>
Sent: Fri, 19 Mar 2004 13:00:03 GMT
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Newbie - trying to extract specific values from XML file.
Hi Charles,
<xsl:template match="Answer[(_at_)name='Female']">
<!-- Your code here -->
</xsl:template>
<xsl:template match="Answer[(_at_)name='ticdesc']">
<xsl:value-of select="TextValue" />
</xsl:template>
OK, I see what you are doing.
Is it better to split each named item up into a different templates?
In most cases I need to either add the value of a named item to a page
or check the value of a named item (e.g. Female) and then adjust the
content accordingly.
Sometimes when I am checking the value of a named item it can result in
large chunks of content being changed that will in turn include other
named values.
Does this make sense?
--
Cheers,
Julian Voelcker
United Kingdom
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list