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 9th, 2010, 10:21 AM
Authorized User
 
Join Date: May 2009
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default How to include namespace in the target xml in a simple way?

Hi,
I have a draft XSLT working which includes the target namespace in the resulting XML. However, I end up adding the namespace attribute in every <xsl:template ... /> tag. Is there a way to include it only once in the XSL instead of so many times? Below is a snippet of what I am currently doing. Can I add "xmlns:ns0=http://Microsoft.LobServices.OracleD.../SHIPMENT_DATA>" so the ns0 will be identified in the XSLT correctly and included in the output XML? Please let meknow if my question isn't clear.

Also, how do I copy the XML/XSLT/code with the indentation intact from my source IDE?

Code:
 
<xsl:template match="s0:componentId">
    <ns0:COMPONENTID        xmlns:ns0="http://Microsoft.LobServices.OracleD.../SHIPMENT_DATA">
          <xsl:value-of select="." />
   </ns0:COMPONENTID>
</xsl:template>
<xsl:template match="s0:productCode">
     <ns0:PRODUCT_CODE xmlns:ns0="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/SHIPMENT_DATA">
          <xsl:value-of select="." />
    </ns0:PRODUCT_CODE>
</xsl:template>
<xsl:template match="s0:shipmentNumber">
     <ns0:SHIPMENTNUMBER xmlns:ns0="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/SHIPMENT_DATA">
            <xsl:value-of select="." />
     </ns0:SHIPMENTNUMBER>
</xsl:template>
<xsl:template match="s0:expirationDate">
    <ns0:EXPIRATION_DATE xmlns:ns0="http://Microsoft.LobServices.OracleDB/2007/03/SCOTT/Table/SHIPMENT_DATA">
         <xsl:value-of select="." />
`     </ns0:EXPIRATION_DATE>
</xsl:template>
Thanks.
 
Old September 9th, 2010, 10:46 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Simply define the namespace on the xsl:stylesheet element, exactly where the other namespaces are defined (e.g. the 'xsl' namespace).
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do we include the namespace and xsd as attributes to the tag anarleti XSLT 5 July 8th, 2010 08:14 AM
error CS0234: The type or namespace name 'Xml' does not exist in the namespace 'Syste shailesh_kumar C# 2008 aka C# 3.0 8 August 20th, 2009 03:11 AM
Need to convert an existing namespace and add new namespace to the SOAP xml Prabeen XSLT 10 April 28th, 2009 10:18 AM
Include Namespace in .aspx.vb?? mikedeepak Visual Studio 2005 6 June 1st, 2007 04:31 AM
an include question (simple i think) darinsee Beginning PHP 7 December 15th, 2004 01:57 AM





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