[XML4Lib] XPath: Selecting nodes grouped with parent?
Jon Gorman
jonathan.gorman at gmail.com
Tue Oct 31 18:04:47 EST 2006
Sorry, apparently didn't send this to the list first time around,
although I see by now Charles Yates has also given the same
answer....ah well, here it is anyway.
........
A little less verbose, and using the type element which seems implied
in the post and not an attribute (although clarification on whether
type really is an element or an attribute might help).
<xsl:transform
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="foo">
<xsl:for-each select="//subcategory[database[type='1']]">
<xsl:copy select=".">
<xsl:copy-of select="./@*" />
<xsl:for-each select="database[type=1]">
<xsl:copy-of select=".">
</xsl:for-each>
</xsl:copy>
</xsl:copy>
</xsl:for-each>
</xsl:template>
</xsl:transform>
Of course, my xslt is a bit rusty, so hopefully I didn't make any
mistakes here in my rush.
Jon Gorman
More information about the XML4Lib
mailing list