Reputation: 13
I have XML document something like below.
<root>
<Book>
<Book_title/>
<author_name/>
</Book>
<Book>
<Book_title/>
<author_name/>
</Book>
<author_details>
<author_name/>
<author_DOB/>
<author_details/>
</root>
So can we compare Book/author_name with author_details/author_name dynamically with XSLT ...??
Upvotes: 1
Views: 40
Reputation: 167471
Define a key
<xsl:key name="author" match="author_details" use="autor_name"/>
then write a template for
<xsl:template match="Book/author_name">
<xsl:copy-of select=". | key('author', .)/author_DOB"/>
</xsl:template>
handle root
and Book
by the identity transformation (e.g. <xsl:mode on-no-match="shallow-copy"/>
in XSLT 3) and add an empty
<xsl:template match="author_details"/>
to prevent copying/outputting those elements.
Upvotes: 1