xsl-list
[Top] [All Lists]

RE: [xsl] Add namespace to element name itself

2008-11-18 07:04:03

Use

<xsl:element name="prefix:{local-name()}" namespace="uri">

where prefix and uri are your desired namespace prefix and namespace URI
respectively.

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

-----Original Message-----
From: V.Ramkumar [mailto:v(_dot_)ramkumar(_at_)macmillansolutions(_dot_)com] 
Sent: 18 November 2008 11:58
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Add namespace to element name itself

Hi List,

I am doing XML to XML Transformation using saxon9.

I have to add namespace to output XML name itself in transformation.

Not like, <pii xmlns="ce"> - This example found in list

I need like this <ce:pii>.

My input XML contains,
      <item-info>
              <jid>YFMIC</jid>
              <aid>1120</aid>
              <pii>S0740-0020(08)00080-4</pii>
              <doi>10.1016/j.fm.2008.04.010</doi>
              <copyright type="unknown" year="2008"/>
      </item-info>

Required output XML,
      <item-info>
              <jid>YFMIC</jid>
              <aid>1120</aid>
              <ce:pii>S0740-0020(08)00080-4</ce:pii>
              <ce:doi>10.1016/j.fm.2008.04.010</ce:doi>
              <ce:copyright type="unknown" year="2008"/>
      </item-info>

My XSL:
      <xsl:template match="*">
              <xsl:copy>
                      <xsl:copy-of select="@*"/>
                      <xsl:apply-templates/>
              </xsl:copy>
      </xsl:template>

      <xsl:template match="pii" priority="3">
              <xsl:element name="{local-name()}" namespace="ce">
                      <xsl:apply-templates select="@*|node()" />
              </xsl:element>
      </xsl:template>
ect..
      </xsl:template>

Regards,
Ramkumar


--~------------------------------------------------------------------
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>
--~--

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