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

Re: QName as attribute value: save and clean up namesp

Subject: Re: QName as attribute value: save and clean up namespace declarations
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Mon, 18 Jun 2012 14:00:00 +0200
Re:  QName as attribute value: save and clean up namesp
Heiko Niemann wrote:

in this example I have an order with different typed items. The type is a
QName in an attribute. There are namespaces declared, having the same
prefix as the 'prefix' in the xsi:type attribute. As you can see there are
more namespaces declared as needed (whatever the reason for that case
might be). Now I would like to clean up and just keep the ones that are
'used' in the xsi:type content. The stylesheet actually already does what
I want, but I would like to know whether there might be a better way to do
it, since it looks a little hackish to me.

   <v:item xsi:type="ns4:lostItem"
           xmlns:ns1="http://prods.com/ns1"
           xmlns:ns2="http://prods.com/ns2"
           xmlns:ns3="http://prods.com/ns3">

I can think of an improvement if you wanted to catch the problem here that the prefix 'ns4' is not declared, in that case I would use e.g.



   <!--identity tranformation; do not copy namespaces; create namespace of
xsi:type-->
   <xsl:template match="*[@xsi:type]">

<xsl:variable name="qname" select="resolve-QName(@xsi:type, .)"/>


here and then work with that value of type QName.
That however would give an error like "FONS0004: Namespace prefix 'ns4' has not been declared" with your sample input, which your current code might intentionally avoid.





--


	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.