Subject:XSL error Author:Don Berning Date:07 Feb 2007 09:19 AM
I am running a transformation on XML and the reply that I am getting is not correct and didn't know what to try. Sample of the data is below. the Output should on give back "250" and not "250 275"
Subject:XSL error Author:Tony Lavinio Date:07 Feb 2007 09:50 AM
You may want to move things around a little, but I've attached a
stylesheet that probably will work better for you.
Remember that the XPath selections work across the entire document,
so that this:
test="Policy/Premium/CoveragePremium/Type/@ID='P'"
means find any ID attribute within any Type element within any Premium
element within any Policy element under the current element.
And also it means that:
select="Policy/Premium/CoveragePremium/PremiumAmount"
means return the set of all PremiumAmount elements under all
CoveragePremium elements under all Premium elements under all Policy
elements under the current element.
So, using either xsl:apply-templates (the preferred method), or
xsl:for-each, you can set the context to the parent of just the
part of the XML tree you are interested in. Then your test and
selection make more sense, since they have a related context.
I find it easiest to just drag things from the right-hand document
tree when writing XSLT; that's what I did here, since the XSLT editor
understands the context it puts in just the part of the path that is
relevant.