I'm having trouble with what should be a simple XSL stylesheet.
I'd like to take an input XML document and add a new element based on matching the input stream. Here's my first attempt at a stylesheet that's failing:
<!--
A simple stylesheet for adding a tag to a document
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Copy the document in its entirety -->
<xsl:template match="*|@*|comment()|processing-instruction()|text()">
<xsl:copy>
<xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
</xsl:copy>
</xsl:template>
<!-- Find the queryItem tag and add a promptInfo child -->
<xsl:template match="queryItem">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
<promptInfo>
<promptType>selectWithSearch</promptType>
</promptInfo>
</xsl:template>
</xsl:stylesheet>
When I run this through Xalan I get the original stream back, without any new tags added. (I'm certain that there's a <queryItem> element in my XML input.) It's as if the match at the top is "too strong" and is executed regardless of the presence of the more specific request to match queryItem.
How do I rewrite this stylesheet to copy the entire document and still honor the match for <queryItem>?
%