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

Re: how to avoid hardcoding xpath-default-namespace in

Subject: Re: how to avoid hardcoding xpath-default-namespace in xsl:stylesheet?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 11 Apr 2014 23:51:39 +0100
Re:  how to avoid hardcoding xpath-default-namespace in
On 11/04/2014 23:35, Larry Evans wrote:
 ><!--How to avoid this hardcoding of xpath-default-namespace?-->
<xsl:template match="html">

the model really is that you _want_ to hardcode the namespace just as you have hardcoded the local-name "html" they are just two parts of the same name. However if you want to match (say) html in no-namepsace and html in the xhtml namespace you could use


html|h:html

where h is bound to http:/www.w3.org/1999/xhtml

or you could use

*:html

which matches html in any namespace

or to do exactly what you said, of just matching the namespace used in the source you can do a two pass strategy that first uses a stylesheet that just uses namespace-uri(/*) on the source document to get the namespace, then transforms the main stylesheet to set the default namespace, then transforms the document with the generated stylesheet.

or finally you can do a two pass strategy that first transforms the source document to a known namespace (say no-namespace") just using

<xsl:template match="*">
<xsl:element name="{local-name()}" namespace="">

then you can transform this document which has a known namespace structure.

David

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.