I have an xml file that looks like this:
<args>
<sometag value="abc" />
<anothertag value="def" />
<atag value="blah" />
</args>
Keep in mind that the tag names inside args can be called anything (I don’t know in advance) Now I have this xml file, which is stored in the $ data variable, which I loaded by calling document () in the xslt stylesheet (this is not support data for xslt file)
I want to take this data and produce the following output:
sometag = ABC & anothertag = Protection & ATAG = blah
so (a very simplified version looks like this:
<xsl:template>
<xsl:variable name="data" select="document('/path/to/xml')" />
<xsl:call-template name='build_string'>
<xsl:with-param name='data' select='$data' />
</xsl:call-template>
</xsl:template>
<xsl:template name="build_string">
<xsl:param name='data'>
<xsl:value-of select='name($data/.)' />=<xsl:value-of select='$data/@value' />
<xsl:if test='$data/following-sibling::node()'>
<xsl:text>&</xsl:text>
<xsl:call-template name="build_str">
<xsl:with-param name="data" select='$nodes/following-sibling::node()' />
</xsl:call-template>
</xsl:if>
</xsl:template>
This almost works, but also prints text nodes from the input file, and I don't want to match text nodes.
source
share