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

Re: Effect of default namespace specifications on impo

Subject: Re: Effect of default namespace specifications on imports
From: Ihe Onwuka <ihe.onwuka@xxxxxxxxx>
Date: Sun, 28 Oct 2012 08:36:30 +0000
Re:  Effect of default namespace specifications on impo
On Sun, Oct 28, 2012 at 1:02 AM, Ihe Onwuka <ihe.onwuka@xxxxxxxxx> wrote:
> On Thu, Oct 25, 2012 at 5:04 PM, G. Ken Holman
> <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
>> At 2012-10-25 16:29 +0100, Ihe Onwuka wrote:
>>>
>>> I am writing an XML conversion, part of which entails bringing things
>>> into the new namespace (from no namespace).
>>>
>>> I have specified namespace X as my default namespace and my XPath
>>> default namespace but all is not as expected.
>>
>>
>> I doubt that will work for you.  Your input is in no namespace so any
>> addressing you need of the input must be in no namespace, so the XPath
>> default namespace should not be set to anything.
>>
>>
>>> I suspect it is because some elements are handled by an imported
>>> identity template. Although this can be worked around this represents
>>> an opportunity to get some clarification as to what the precise rules
>>> are as relates to default namespace specfications and imported
>>> stylesheets.
>>
>>
>> There are no such rules regarding a relationship between default namespace
>> specifications and imported stylesheets.  Each stylesheet fragment is
>> standalone.  Any use of the XML default namespace or the XPath default
>> namespace is in scope of only the stylesheet fragment.  There is no
>> knowledge between stylesheet fragments of the use of the namespaces in other
>> fragments.
>>
>> And I suspect the identity template will not help you if you have to change
>> the namespace for each element.
>>
>
> Here is the algorithm I used to handle renamespacing and other
> template processing in a single pass (well it worked for me).
>
> Import the identity template.
> Make the new namespace the default namespace of the main stylesheet.
>
> The following template will renamespace all elements  that do not have
> an explicit template rule.
>
>   <xsl:template match="*">
>     <xsl:element name="{local-name()}">
>       <xsl:apply-templates/>
>     </xsl:element>
>   </xsl:template
>
> For your other template rules, any elements that you <xsl:copy> will
> stubbornly stay in the old namespace so replace any <xsl:copy>
> elements in other templates with <xsl:element name="{local-name()}">.

Above is the ambidextrous solution (XSLT 1.0 and 2.0)

For 2.0 only the <xsl:element name="{local-name}"> can be replaced by
<xsl:copy copy-namespaces="no">

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.