xsl-list
[Top] [All Lists]

RE: copying xmlns: attribute

2005-03-31 07:28:15


Hi,
     I was trying with xsl:copy  but without the xsl:for-each and when I
did get the for-each right, I somehow missed out on the xsl:copy

Thanks for pointing this out.

Cheers,
Omprakash.V













                                                                                
                                   
                    "Michael Kay"                                               
                                   
                    <mike(_at_)saxonic        To:     
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>                              
   
                    a.com>               cc:     (bcc: omprakash.v/Polaris)     
                                   
                                         Subject:     RE: [xsl] copying xmlns: 
attribute                           
                    03/31/2005                                                  
                                   
                    07:35 PM                                                    
                                   
                    Please                                                      
                                   
                    respond to                                                  
                                   
                    xsl-list                                                    
                                   
                                                                                
                                   
                                                                                
                                   




In the XPath data model, namespaces are not attributes. So @* doesn't
select
them. To copy namespaces you need to use xsl:copy-of select="namespace::*"

However if instead of

<xsl:variable name="rootnode" select="name(.)"/>
<xsl:element name="{$rootnode}">

you do

<xsl:copy>

then namespaces will be copied automatically. (In fact, one of the reasons
for using xsl:element in preference to xsl:copy is when you don't want
namespaces copied.)

Michael Kay
http://www.saxonica.com/

-----Original Message-----
From: omprakash(_dot_)v(_at_)polaris(_dot_)co(_dot_)in 
[mailto:omprakash(_dot_)v(_at_)polaris(_dot_)co(_dot_)in]
Sent: 31 March 2005 14:06
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] copying xmlns: attribute


Hi,

      Got this far by myself.

         Iam using the following code to copy an element
along with its
attibutes to the result tree from a context node which is
elsewhere in the
document. The context node is in fact the root element.
However, the xmlns:
attribute is not getting copied.

   <xsl:template match="/">
     <xsl:for-each select="//root/*[1]">
     <xsl:variable name="rootnode" select="name(.)"/>
     <xsl:element name="{$rootnode}">
     <xsl:copy-of select="@*"/>
     <xsl:apply-templates select="/" mode="inside">
          <xsl:with-param name="rootnode" select="$rootnode"/>
     </xsl:apply-templates>

     </xsl:element>
     </xsl:for-each>
   </xsl:template>


I have used xsl:copy-of select="@*" earlier and I know that it copies
xmlns: attributes.
Also, in the inner call to apply-templates, I have to select
"/" once again
with a different mode as otherise only one node is getting
copied if I use
@*|node()

My xhtml snippet is as follows:

<table>
<tr>
<root>
<slideshow xmlns="urn:hl7-org/v3" title="Sample Slide Show"
date="Date of
publication" author="Yours Truly">
<td><a href="file:///">

:
:
:

</slideshow>

Hoping to get a quick reply.

Cheers,
Omprakash.V













This e-Mail may contain proprietary and confidential
information and is sent for the intended recipient(s) only.
If by an addressing or transmission error this mail has been
misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of
reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message,
contents or its attachment other than by its intended
recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--






This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to 
you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, 
dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its 
attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>