[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

More on my problem with namespaces

Subject: More on my problem with namespaces
From: Nick Leaton <nickle@xxxxxxxxx>
Date: Tue, 9 Nov 2010 15:59:10 +0000
 More on my problem with namespaces
I thought I had a solution to my namespace problem, but on
investigation I haven't
On further investigation, I haven't got it going, so I've produced a
cut down version
showing the problem

here is a test xml file

===================
<?xml version="1.0" encoding="UTF-8"?>
<bonds>
   <isin>123</isin>
   <isin>456</isin>
   <isin>789</isin>
</bonds>
===================


Here is the xslt cut down
===================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:calypso="http://www.calypso.com/xml"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   version="2.0">

   <xsl:output method="xml" indent="yes"/>

   <xsl:template match="/">
       <bonds>
           <xsl:for-each select="//isin">
           <bond>
               <calypso:secCode>
                   <calypso:name>ISIN</calypso:name>
                   <xsl:element name="calypso:value">
                       <xsl:attribute
name="xsi:type">ns3:string</xsl:attribute>
                       <xsl:attribute
name="ns3">http://www.w3.org/2001/XMLSchema</xsl:attribute>
                       <xsl:value-of select="."/>
                   </xsl:element>
               </calypso:secCode>
           </bond>
       </xsl:for-each>
       </bonds>
   </xsl:template>
</xsl:stylesheet>

===================

Here is the output

===================
<?xml version="1.0" encoding="UTF-8"?>
<bonds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:calypso="http://www.calypso.com/xml">
  <bond>
     <calypso:secCode>
        <calypso:name>ISIN</calypso:name>
        <calypso:value xsi:type="ns3:string"
ns3="http://www.w3.org/2001/XMLSchema">123</calypso:value>
     </calypso:secCode>
  </bond>
  <bond>
     <calypso:secCode>
        <calypso:name>ISIN</calypso:name>
        <calypso:value xsi:type="ns3:string"
ns3="http://www.w3.org/2001/XMLSchema">456</calypso:value>
     </calypso:secCode>
  </bond>
  <bond>
     <calypso:secCode>
        <calypso:name>ISIN</calypso:name>
        <calypso:value xsi:type="ns3:string"
ns3="http://www.w3.org/2001/XMLSchema">789</calypso:value>
     </calypso:secCode>
  </bond>
</bonds>
===================

Here is the desired output

===================
<?xml version="1.0" encoding="UTF-8"?>
<bonds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:calypso="http://www.calypso.com/xml">
  <bond>
     <calypso:secCode>
        <calypso:name>ISIN</calypso:name>
        <calypso:value xsi:type="ns3:string"
xmlns:ns3="http://www.w3.org/2001/XMLSchema">123</calypso:value>
     </calypso:secCode>
  </bond>
  <bond>
     <calypso:secCode>
        <calypso:name>ISIN</calypso:name>
        <calypso:value xsi:type="ns3:string"
xmlns:ns3="http://www.w3.org/2001/XMLSchema">456</calypso:value>
     </calypso:secCode>
  </bond>
  <bond>
     <calypso:secCode>
        <calypso:name>ISIN</calypso:name>
        <calypso:value xsi:type="ns3:string"
xmlns:ns3="http://www.w3.org/2001/XMLSchema">789</calypso:value>
     </calypso:secCode>
  </bond>
</bonds>
===================


The difference is that I need

ns3="http://www.w3.org/2001/XMLSchema"

output as

xmlns:ns3="http://www.w3.org/2001/XMLSchema"


Any ideas?
--
Nick

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.