Re: [xsl] XSLT for toplevel element in xml

Subject: Re: [xsl] XSLT for toplevel element in xml
From: Nishi Bhonsle <nishi.bhonsle@xxxxxxxxxx>
Date: Tue, 18 May 2004 08:58:56 -0700
Thanks, Josh, that helped.

Nishi.

Josh Canfield wrote:

> <abc:configuration  xmlns:abc="http://oracle.com/xmlns/abcd/configuration";
> <xsl:stylesheet ... xmlns:abc="http://www.oracle.com/abcd/configuration";>
>
> I assume you want these to be the same namespace?
>
> -----Original Message-----
> From: Nishi Bhonsle [mailto:nishi.bhonsle@xxxxxxxxxx]
> Sent: Monday, May 17, 2004 2:08 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] XSLT for toplevel element in xml
>
> One.xml looks like
> --------------------
> <?xml version = '1.0' encoding = 'UTF-8'?>
> <!-- Example configuration file. The schema rules are defined in
>      the schema definition file configuration.xsd which also
>      includes explanatory comments -->
> <abc:configuration xmlns:abc="http://oracle.com/xmlns/abcd/configuration"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://oracle.com/xmlns/abcd/configuration configuration.xsd" cache="false" rmi="true">
>
>   <drillOutDir>/files</drillOutDir>
>
>   <started status="true"></started>
>
>   <server useLogFile="true" logLevel="error">
>     <activation enabled="true" maxSessions="20" timeout="30">
>       </activation>
>   </server>
>  </abc:configuration>
>
> ==========================================================
>
> One.xsl looks like
> ------------------
>  <?xml version="1.0" encoding="UTF-8"?>
>  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:fo="http://www.w3.org/1999/XSL/Format"; xmlns:abc="http://www.oracle.com/abcd/configuration";>
>   <xsl:output method="xml" encoding="UTF-8"/>
>
>  <xsl:template match="abc:configuration">
>    <xsl:copy>
>     <xsl:copy-of select="@*[local-name() != 'rmi']"/>
>     <xsl:attribute name="useConnectionMgmt"><xsl:text>true</xsl:text></xsl:attribute>
>     <xsl:attribute name="metadataReposAvailable"><xsl:text>true</xsl:text></xsl:attribute>
>    </xsl:copy>
>   </xsl:template>
>
>  <xsl:template match="*">
>   <xsl:copy>
>    <xsl:copy-of select="@*"/>
>    <xsl:apply-templates/>
>   </xsl:copy>
>  </xsl:template>
> </xsl:stylesheet>
>
> Michael Kay wrote:
>
> > template match="abc:configuration"
> >
> > is correct. Perhaps you got the namespace URI wrong. Show us a complete
> > example of the problem.
> >
> > Michael Kay
> >
> > > -----Original Message-----
> > > From: Nishi Bhonsle [mailto:nishi.bhonsle@xxxxxxxxxx]
> > > Sent: 17 May 2004 17:59
> > > To: xsl list
> > > Subject: [xsl] XSLT for toplevel element in xml
> > >
> > >
> > > Hi:
> > >
> > > I have a xml say One.xml that has the toplevel element as the
> > > following --
> > >
> > > <abc:configuration
> > > xmlns:abc="http://oracle.com/xmlns/abc/configuration";
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; locale="en"
> > > cache="false" rmi="true">
> > > ...
> > > ..
> > > ....
> > > ....
> > > </abc:configuration>
> > >
> > >
> > > I need to transform One.xml to Two.xml in such a way that
> > > Two.xml contains some additional attributes in the
> > > abc:configuration tag
> > > ie
> > >
> > > <abc:configuration
> > > xmlns:abc="http://oracle.com/xmlns/abc/configuration";
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; locale="en"
> > > cache="false" rmi="true" new_tag="true" new_tag2="false">
> > >
> > > I tried to use several ways as rules for the <xsl:template
> > > match=.....--
> > > 1) template match="abc:configuration"
> > > 2) template match="local-name(abc:configuration)
> > > 3) template match="@*[(starts-with(name(),'abc:'))]"
> > >
> > > But it does not work. Only after replacing the
> > > abc:configuration by configuration in One.xml and writing a
> > > rule to match configuration it works.
> > > Can you suggest a resolution to this?
> > >
> > > Thanks, Nishi.

Current Thread