This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: transforming XML into XML using XSLT.
- From: Larry Garfield <lgarfiel at students dot depaul dot edu>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 13 Aug 2002 17:10:27 -0500
- Subject: Re: [xsl] transforming XML into XML using XSLT.
- Organization: DePaul University
- References: <EE1ED172E985D411A27B00508BE30A5E01748B72@uswaumsx11medge.med.ge.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Two alternate methods you may want to try:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output type="xml"/>
<xsl:template match="/">
<catalog>
<xsl:apply-templates select="cd"/>
</catalog>
</xsl:template>
<xsl:template match="cd">
<cd>
<xsl:value-of select="title"/>
<xsl:value-of select="artist"/>
</cd>
</xsl:template>
</xsl:stylesheet>
or, since you're simply stripping out selected tags, you can use an
identity transform and just block certain elements.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output type="xml"/>
<!-- Identity transform, passes nodes through untouched -->
<xsl:template match="@*|node()|text()">
<xsl:copy>
<xsl:apply-templates select="@*|*|text()" />
</xsl:copy>
</xsl:template>
<!-- Match these specific nodes and do absolutely nothing with them,
which keeps the Identity transform from catching it. -->
<xsl:template match="country|company|price|year" />
</xsl:stylesheet>
Cheers.
"Shaikh, Neelkamal (MED, Oracle)" wrote:
>
> Thank you.
> Please find below the Input XML file , Required Output XML file and the
> XSLT I had developed.
>
> Input XML File
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <?xml-stylesheet type="text/xsl" href="designCatalog.xsl"?>
> <catalog>
> <cd>
> <title>Empire Burlesque</title>
> <artist>Bob Dylan</artist>
> <country>USA</country>
> <company>Columbia</company>
> <price>10.90</price>
> <year>1985</year>
> </cd>
> <cd>
> <title>Hide your heart</title>
> <artist>Bonnie Tyler</artist>
> <country>UK</country>
> <company>CBS Records</company>
> <price>9.90</price>
> <year>1988</year>
> </cd>
> </catalog>
>
> Required Output XML.
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <catalog>
> <cd>
> <title>Empire Burlesque</title>
> <artist>Bob Dylan</artist>
> </cd>
> <cd>
> <title>Hide your heart</title>
> <artist>Bonnie Tyler</artist>
> </cd>
> </catalog>
>
> XSLT used:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output type="xml"/>
> <xsl:template match="/">
> <catalog>
> <xsl:for-each select="catalog/cd">
> <cd>
> <xsl:value-of select="title"/>
> <xsl:value-of select="artist"/>
> </cd>
> </xsl:for-each>
> </catalog>
> </xsl:template>
> </xsl:stylesheet>
>
> I don't have an exclusive processor , I am viewing the output in
> Internet explorer 5.5.
>
> -----Original Message-----
> From: Charles Knell [mailto:cknell@onebox.com]
> Sent: Tuesday, August 13, 2002 3:48 PM
> To: xsl-list@lists.mulberrytech.com
> Subject: Re: [xsl] transforming XML into XML using XSLT.
>
> It would be far easier to give you an example XSLT if you gave us
> examples
> of "before" and "after" versions of your XML.
>
> --
> Charles Knell
> cknell@onebox.com - email
>
> ---- "Shaikh, Neelkamal (MED, Oracle)" <Neelkamal.Shaikh@med.ge.com>
> wrote:
> > Hi,
> >
> > Is it possible to convert XML[having useful +unnecessary data ]
> > -----to-----> XML [having Useful data] using XSLT.Could you please
> > help
> > me out with an example.
> >
> > Thanks in advance,
> > Neel.
> >
> > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> >
> >
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
--
Larry Garfield AIM: LOLG42
lgarfiel@students.depaul.edu ICQ: 6817012
-- "If at first you don't succeed, skydiving isn't for you." :-)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list