Connecting Tech Pros Worldwide Forums | Help | Site Map

getting the output in the form of xml

sp
Guest
 
Posts: n/a
#1: Jan 24 '06
hai

i have got
1. an xml file
2. an xsl file

and my xsl file filters the xml based on attribute value

and the output i receive is in the ordinary format

could any help in getting the output in the form of xml

i tried

<xsl:output method="xml" />

this is not working

i worked on VC++ to know the output string but i am receiving only the
tag values as output i need the entire xml matching the filter
condition.

plz help me to get the output in the correct format

thanks
praveen


Martin Honnen
Guest
 
Posts: n/a
#2: Jan 24 '06

re: getting the output in the form of xml




sp wrote:

[color=blue]
> i have got
> 1. an xml file
> 2. an xsl file
>
> and my xsl file filters the xml based on attribute value
>
> and the output i receive is in the ordinary format[/color]

What exactly is "the ordinary format", plain text, or HTML, or what else?

[color=blue]
> could any help in getting the output in the form of xml
>
> i tried
>
> <xsl:output method="xml" />
>
> this is not working[/color]

Well what exactly does your stylesheet look like, how does your input
XML look?
Make sure that your XSLT stylesheet creates result elements with e.g.
<xsl:copy>
or with
<xsl:element>
or with literal result elements, it does not suffic to use e.g.
<xsl:value-of select="." />
to create elements.



--

Martin Honnen
http://JavaScript.FAQTs.com/
sp
Guest
 
Posts: n/a
#3: Jan 25 '06

re: getting the output in the form of xml


the xml file i used


<catalog>
<cd>
<title year="1990">Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
</cd>
<cd>
<title year="1995">Hide your heart</title>
<artist>Bonnie Tyler</artist>
<price>9.90</price>
</cd>
<cd>
<title year="1995">Greatest Hits</title>
<artist>Dolly Parton</artist>
<price>9.90</price>
</cd>
<cd>
<title year="1995">Still got the blues</title>
<artist>Gary Moore</artist>
<price>10.20</price>
</cd>
<cd>
<title year="1998">Eros</title>
<artist>Eros Ramazzotti</artist>
<price>9.90</price>
</cd>
<cd>
<title year="1998">One night only</title>
<artist>Bee Gees</artist>
<price>10.90</price>
</cd>
</catalog>


the output expected


<cd>
<title year="1990">Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
</cd>


the xsl used


<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="/">
<xsl:for-each select="/catalog/cd[title[@year='1990']]">
<xsl:value-of select="." />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

my output is

Empire Burlesque Bob Dylan 10.90


is there anything i have to change in the xsl to get the output in the
xml format

sp
Guest
 
Posts: n/a
#4: Jan 25 '06

re: getting the output in the form of xml


the xml file i used


<catalog>
<cd>
<title year="1990">Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
</cd>
<cd>
<title year="1995">Hide your heart</title>
<artist>Bonnie Tyler</artist>
<price>9.90</price>
</cd>
<cd>
<title year="1995">Greatest Hits</title>
<artist>Dolly Parton</artist>
<price>9.90</price>
</cd>
<cd>
<title year="1995">Still got the blues</title>
<artist>Gary Moore</artist>
<price>10.20</price>
</cd>
<cd>
<title year="1998">Eros</title>
<artist>Eros Ramazzotti</artist>
<price>9.90</price>
</cd>
<cd>
<title year="1998">One night only</title>
<artist>Bee Gees</artist>
<price>10.90</price>
</cd>
</catalog>


the output expected


<cd>
<title year="1990">Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
</cd>


the xsl used


<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="/">
<xsl:for-each select="/catalog/cd[title[@year='1990']]">
<xsl:value-of select="." />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

my output is

Empire Burlesque Bob Dylan 10.90


is there anything i have to change in the xsl to get the output in the
xml format

Closed Thread