Reputation: 933
Lets say a have this basic xml document:
<result name="response" numFound="73" start="0">
<doc>
<str name="contentType">Content1</str>
<str name="content">Some content here</str>
</doc>
<doc>
<str name="contentType">Content2</str>
<str name="content">Some other content</str>
</doc>
</result>
I plan to use a different template for each content type. What are the template match arguments? I haven't been able to figure out how to match for the other children of doc when only the contentType field is a specific value.
Upvotes: 1
Views: 10295
Reputation: 101652
It sounds like what you're going for is something like this:
<xsl:template match="doc[str[@name = 'contentType'] = 'Content1']
/str[name = 'Content']">
<!-- Process Content1 content str -->
</xsl:template>
<xsl:template match="doc[str[@name = 'contentType'] = 'Content2']
/str[name = 'Content']">
<!-- Process Content2 content str -->
</xsl:template>
Or perhaps something like this?
<xsl:template match="doc[str[@name = 'contentType'] = 'Content1']">
<!-- Process Content1 doc -->
</xsl:template>
<xsl:template match="doc[str[@name = 'contentType'] = 'Content2']">
<!-- Process Content2 doc -->
</xsl:template>
Would either of those be what you're looking for?
Upvotes: 6