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

Re: Handling a missing namespace

Subject: Re: Handling a missing namespace
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Thu, 05 Jul 2012 18:38:37 +0200
Re:  Handling a missing namespace
Aaron Johnson wrote:
Hello

I'm looking for advice on how to handle 2 different xml files in 1
transform, one has a namespace, the other doesn't.

Example with namespace...

<ns1:BigCardThing xmlns:ns1="http://xyz.com/ns1/blah/blahspec">
                 <ns1:bigCard>
                                 <ns1:surname>Lastname</ns1:surname>

<ns1:givenName1>Firstname</ns1:givenName1>
                                 <ns1:dateOfBirth>1971-04-04</ns1:dateOfBirth>
                                 <ns1:gender>M</ns1:gender>
                 </ns1:bigCard>
</ns1:BigCardThing>

...without

<BigCardThing >
                 <bigCard>
                                 <surname>Lastname</surname>
                                 <givenName1>Firstname</givenName1>
                                 <dateOfBirth>1971-04-04</dateOfBirth>
                                 <gender>M</gender>
                 </bigCard>
</BigCardThing>

Is there a way for xslt to look for the missing namespace and then
'add it' in the transform?

<xsl:template match="*[not(namespace-uri())]">
<xsl:element name="ns1:{local-name()}" namespace=""http://xyz.com/ns1/blah/blahspec">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>




--

	Martin Honnen --- MVP Data Platform Development
	http://msmvps.com/blogs/martin_honnen/

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.