RE: [xsl] Creating namespace nodes

Subject: RE: [xsl] Creating namespace nodes
From: <tomas.vanek@xxxxxxxxxxxxx>
Date: Tue, 7 Jun 2005 13:14:58 +0200
Great, the right time for me to swith to 2.0....
Unfortunately I am working in "standard" environment (app. servers,
web-browsers), so it takes couple of years to switch to 2.0 in the
mainstream :-D
tomi

-----Original Message-----
From: George Cristian Bina [mailto:george@xxxxxxx]
Sent: Tuesday, June 07, 2005 1:05 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Creating namespace nodes

Adding xsl:namespace

<xsl:template match="h">
     <xsl:copy>
       <xsl:namespace name="temp" select="'http://whatever'"/>
       <xsl:apply-templates select="node() | @*"/>
     </xsl:copy>
   </xsl:template>

will give:

<h xmlns:temp="http://whatever"; id="6"/>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


tomas.vanek@xxxxxxxxxxxxx wrote:
> Do not expect miracles!
> The result will be the same - you add a dummy attribute with desired
> namespace to your element and so you force the XSLT engine to add the
> namespace. In XSLT 1.0 you have hard time to play with namespaces
> nicely :-(
>
> Are this issues addressed in XSLT 2.0 (adding namespace nodes to
> elements)?
>
> I could not find a nice solution for WSDL, where you get the namespace

> in an attribute.. I had to kick-off all the namespaces staff (using
> local-name() function in all Xpath queries :-( Any ideas? Is it solved

> in XSLT 2.0?
>
> Thanks,
> tomi
>
> -----Original Message-----
> From: Mukul Gandhi [mailto:mukul_gandhi@xxxxxxxxx]
> Sent: Tuesday, June 07, 2005 12:43 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] Creating namespace nodes
>
> Hi George,
>   I got the same output that you have written ..
> Accidently some nodes from the XML got deleted, while I hit the send
> button ..
>
> I'll study Tomi's stylesheet ..
>
> Regards,
> Mukul
>
> --- George Cristian Bina <george@xxxxxxx> wrote:
>
>
>>Hi Mukul,
>>
>>With Saxon 8.4 I get:
>>
>><?xml version="1.0" encoding="UTF-8"?> <a id="10">
>>      <b id="9">
>>           <c id="8">
>>                <d id="7">
>>                     <a id="5">
>>                          <h
>>xmlns:ns0="http://whatever"; ns0:temp=""
>>id="6"/>
>>                     </a>
>>                </d>
>>           </c>
>>      </b>
>></a>
>>
>>which looks ok to me. Note that it is not what you have as desired
>>output as you do not include there the temp attribute.
>>
>>Best Regards,
>>George
>>
>
> ---------------------------------------------------------------------
>
>>George Cristian Bina
>><oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
>>http://www.oxygenxml.com
>>
>>
>>Mukul Gandhi wrote:
>>
>>>I am using XSLT 1.0 ;)
>>>
>>>"I need to write a identity transform, and add a namespace node to a
>
>
>>>particular element in the
>>
>>result
>>
>>>tree.."
>>>
>>>I have written the following XSLT (1.0) stylesheet
>>
>>so
>>
>>>far ..
>>>
>>><?xml version="1.0"?>
>>><xsl:stylesheet
>>>xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>>>version="1.0">
>>>
>>><xsl:output method="xml" indent="yes" />
>>>
>>><xsl:template match="node() | @*">
>>>   <xsl:copy>
>>>      <xsl:apply-templates select="node() | @*" />
>>>   </xsl:copy>
>>></xsl:template>
>>>
>>><xsl:template match="h">
>>>  <xsl:copy>
>>>    <xsl:attribute name="temp"
>>>namespace="http://whatever"; />
>>>    <xsl:apply-templates select="node() | @*" />
>>>  </xsl:copy>
>>></xsl:template>
>>>
>>></xsl:stylesheet>
>>>
>>>The input XML is -
>>>
>>><?xml version="1.0"?>
>>><a id="10">
>>>  <b id="9">
>>>    <c id="8">
>>>      <d id="7">
>>>        <a id="5">
>>>          <h id="6" />
>>>        </a>
>>>      </d>
>>>    </c>
>>>  </b>
>>></a>
>>>
>>>The output produced with the above stylesheet is -
>>>
>>>Warning: Running an XSLT 1.0 stylesheet with an
>>
>>XSLT
>>
>>>2.0 processor
>>><?xml version="1.0" encoding="UTF-8"?> <a id="10">
>>>     <b id="9">
>>>          <c id="8">
>>>               <d id="7">
>>>                    <a id="5">
>>>                         <h temp: id="6"/>
>>>
>>>                    </a>
>>>               </d>
>>>          </c>
>>>     </b>
>>></a>
>>>
>>>I am using Saxon 8.4 ..
>>>
>>>I desire output -
>>>
>>><?xml version="1.0" encoding="UTF-8"?> <a id="10">
>>>     <b id="9">
>>>          <c id="8">
>>>               <d id="7">
>>>                    <a id="5">
>>>                         <h
>>>xmlns:temp="http://whatever"; id="6"/>
>>>                    </a>
>>>               </d>
>>>          </c>
>>>     </b>
>>></a>
>>>
>>>I'll appreciate any help ..
>>>
>>>Regards,
>>>Mukul
>>>
>>>
>>>
>>>__________________________________________________
>>>Do You Yahoo!?
>>>Tired of spam?  Yahoo! Mail has the best spam
>>
>>protection around
>>
>>>http://mail.yahoo.com
>>
>>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
>
>
> This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information.  If you have
received it in error, please notify the sender immediately and delete
the original.  Any other use of the email by you is prohibited.



This message is for the designated recipient only and may contain privileged,
proprietary, or otherwise private information.  If you have received it in
error, please notify the sender immediately and delete the original.  Any
other use of the email by you is prohibited.

Current Thread