Wrox Programmer Forums
|
BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0
This is the forum to discuss the Wrox book XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition by Michael Kay; ISBN: 9780470192740
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 2nd, 2011, 09:12 AM
Authorized User
 
Join Date: Apr 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default identity transform excluding xml element

Hello,

I am trying identity transformation which will also exclude one of the element with it's value. However, the template was not getting match and output xml file still contains excluded element. Can you please suggest what's gone wrong in the below sample xslt

sample xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

<xsl:template match="oh"/>

</xsl:stylesheet>

input xml:
<ts-ut id="09" dttyp="x-text/html" rstyp="str">
<sr>
<oh id="1" x="b">{1}</oh>Dwnld Cter<oh id="2" x="b">{2}</oh>
</sr>
<tg>
<oh id="1" x="b">{1}</oh>
<oh id="2" x="b">{2}</oh>
</tg>

output xml:
<ts-ut id="09" dttyp="x-text/html" rstyp="str">
<sr>
Dwnld Cter
</sr>
<tg>
</tg>

Thanks.
 
Old November 2nd, 2011, 09:22 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The input XML you have shown isn't well-formed - there is no closing tag for the ts-ut element. This means I can't reproduce the problem, and it also leads me to suspect that you might have inadvertently omitted part of the XML source. The most likely reason that the match="oh" template is not matching is that the oh element is within the scope of a default namespace declaration.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Transform Attribute based xml to element based xml pallone XSLT 6 February 2nd, 2016 07:59 AM
XSL sort on identity transform imshriram XSLT 1 October 14th, 2011 03:57 PM
XSLT output to HTML - xml element text should look exactly as laid out in xml element DjGogga XSLT 4 July 21st, 2011 05:39 PM
Getting @@IDENTITY in Row Transform afward SQL Server DTS 2 September 28th, 2005 09:56 AM
transform element contents advisor XSLT 1 September 16th, 2003 12:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.