|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Adding namespace to an XML through XSL
Thanks a lot Lars. That seems to have done the trick.
I have been having a real tough with incorporating
the namespace but this worked beautifully! Really
appreciate it.
Kanthi
--- Lars Huttar <lars_huttar@xxxxxxx> wrote:
> xsl:copy-of copies nodes in the source tree to
> equivalent
> nodes in the result tree, with the same name and
> namespace
> (and the serializer will add declarations such as
> xmlns="" to make
> sure that Element1 is still in no namespace, just as
> it was in
> the source tree).
>
> In order to change the namespace during the
> transform, you
> can use an identity transform, modified to change
> the namespace
> of each element. E.g.:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" version="1.0"
> encoding="UTF-8" indent="yes"/>
>
> <xsl:template match="*" priority="3">
> <xsl:element name="{local-name()}"
> namespace="Something">
> <xsl:apply-templates select="@*|node()" />
> </xsl:element>
> </xsl:template>
>
> <xsl:template match="@*|node()">
> <xsl:copy>
> <xsl:apply-templates select="@*|node()"/>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
>
> HTH,
> Lars
>
> > -----Original Message-----
> > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On
> Behalf Of Kanthi
> > Sent: Tuesday, December 30, 2003 10:06 AM
> > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Adding namespace to an XML through
> XSL
> >
> >
> > Hi there -
> >
> > I am having problems adding a namespace using an
> xsl
> > to an xml with no namespaces.
> >
> > My sample xml looks like this
> > <MainElement>
> > <Element1>
> > <Element2>
> > <Element3>
> > :
> > :
> > </Element3>
> > </Element2>
> > </Element1>
> > </MainElement>
> >
> > And I want to add a namespace to the <MainElement
> > xmlns="Something"> without any prefix.
> >
> > I am doing the following in my xsl
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > xmlns="Something">
> > <xsl:output method="xml" version="1.0"
> > encoding="utf-8" indent="yes"
> > omit-xml-declaration="yes"/>
> >
> > <xsl:template match="MainElement">
> > <MainElement xmlns="Something">
> > <xsl:copy-of select="."/>
> > </MainElement>
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> > But the problem is that <Element1> looks like this
> > <Element1 xmlns="">
> >
> > Any ideas on how to get round this? I am not
> exactly
> > sure how to use "xsl:namespace-alias" for this or
> > whether that will help?
> >
> >
> > Thanks
> > Kanthi
> >
> > __________________________________
> > Do you Yahoo!?
> > Find out what made the Top Yahoo! Searches of 2003
> > http://search.yahoo.com/top2003
> >
> > XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
> >
>
> XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
>
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








