Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT 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 September 18th, 2014, 02:25 PM
Registered User
 
Join Date: Sep 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Simple node copying from XML to XML

I have an XML fragment:

Code:
<?xml version="1.0" encoding="UTF-8"?>
		<POSLog xmlns="http://www.nrf-arts.org/IXRetail/namespace/"
        xmlns:dtv="http://www.datavantagecorp.com/xstore/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.nrf-arts.org/IXRetail/namespace/POSLog.xsd">
<dtv:PosTransactionProperties>
<dtv:PosTransactionPropertyCode><![CDATA[RECEIPT_EMAIL_ADDRESS]]></dtv:PosTransactionPropertyCode>
<dtv:PosTransactionPropertyValue><![CDATA[[email protected]]]></dtv:PosTransactionPropertyValue>
</dtv:PosTransactionProperties>
</POSLog>
And the following XSLT <stylesheet> code, which now copies only data from the specific selected element.

Code:
<xsl:stylesheet version="2.0"
                 xmlns:dtv="http://www.datavantagecorp.com/xstore/"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        >
   
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="//POSLog">
<POSLog>
           		<xsl:for-each select = "../dtv:PosTransactionProperties[dtv:PosTransactionPropertyCode='RECEIPT_EMAIL_ADDRESS']/dtv:PosTransactionPropertyValue[string-length() &gt; 0]" >
            	<xsl:copy-of select = "." />
       		</xsl:for-each>
</POSLog>
</xsl:template>


</xsl:stylesheet>
But, based on my requirement, I need to copy to the output XML entire node <dtv:PosTransactionProperties>, could you, please, advice how to do this copying.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a node to an existing xml node list. codehelp C# 2008 aka C# 3.0 2 October 12th, 2009 07:41 AM
XML::Simple parsing xml geek.shrek Perl 1 August 19th, 2009 10:32 PM
how to append child node after an node in XML + C# vishnu108mishra XML 5 November 13th, 2007 05:30 AM
copying xml attributes golddog XSLT 1 September 12th, 2007 01:05 PM
Copying Source Node attributes to output node pvsat XSLT 2 November 3rd, 2005 09:46 AM





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