Hi all,
I have some pretty flat input xml, for example:
Code:
<root>
<person1name>Bob<person1name>
<person2name>Fred<person2name>
<person3name>Harry<person3name>
</root>
I have an xsl file which contains a template called "tidyup", this improves the structure, e.g.:
Code:
<root>
<people>
<person id="1">
<name>Bob</name>
</person>
<person id="2">
<name>Fred</name>
</person>
..and so on
I then have a "main" xsl file which is called by a server, this is the stylesheet used to transform the xml from one format into another.
My aim is for it to first call the tidyup stylesheet to improve the input xml structure, and then transform the tidied xml into a completely new format.
So far my "main" stylesheet looks like:
Code:
...
<xsl:include href="tidyup.xsl" />
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="root">
<xsl:call-template name="tidyup" />
</xsl:template>
<xsl:template match="/">
<newxml>
<xsl:value-of select="//name[.='Fred']" />
</newxml>
</xsl:template>
As you can see from above, I am trying to output any "name" nodes with the value Fred.
However, the second template (matching to "/") seems to be trying to run against the original xml, so I would need to look for "//person2name" instead.
Please could someone offer any advice as to how I can get the second template (matching to "/") to run against the tidied xml (i.e. the result of the first template, matching to "root" and calling "tidyup").
Any help appreciated, thanks.