Subject: Re: [xsl] xml elements as output after xslt parsing From: Lars Huttar <lars_huttar@xxxxxxx> Date: Mon, 11 Oct 2010 10:39:17 -0500 |
Sudheshna, What are you using to see the output? A browser? When I run the stylesheet below on the input below, I get the following output: <?xml version="1.0" encoding="UTF-8"?> <newCD><title>Empire Burlesque</title></newCD> However if I view this output in a browser, nothing shows up. But if I then "view source", I can see the above output XML. HTH, Lars On 10/11/2010 3:27 AM, sudheshna iyer wrote: > Thank you for the explanation. But I also want to print <newCD>. With the > change " <xsl:copy-of select="*"/>" I don't see any output. > > Input: > <?xml version="1.0" encoding="ISO-8859-1"?> > <!-- Edited by XMLSpy. --> > <catalog> > <cd> > <title>Empire Burlesque</title> > > </cd> > </catalog> > > XSL: > <?xml version="1.0" encoding="ISO-8859-1"?> > <!-- Edited by XMLSpy. --> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:template match="/"> > <xsl:apply-templates/> > </xsl:template> > > <xsl:template match="cd"> > <newCD> > <xsl:copy-of select="*"/> > </newCD> > </xsl:template> > </xsl:stylesheet> > > Needed Output: > <newCD> > <title>Empire Burlesque</title> > </newCD> > > > > > > > ----- Original Message ---- > From: Lars Huttar <lars_huttar@xxxxxxx> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Cc: sudheshna iyer <sudheshnaiyer@xxxxxxxxx> > Sent: Sat, October 9, 2010 11:34:33 PM > Subject: Re: [xsl] xml elements as output after xslt parsing > > On 10/9/2010 5:04 PM, sudheshna iyer wrote: >> I want to traverse through two xmls and produce 3rd xml from xslt. I want to >> see >> >> the xml elements instead of just the values in the output. >> >> Input: >> >> <?xml version="1.0" encoding="ISO-8859-1"?> >> <!-- Edited by XMLSpy. --> >> <catalog> >> <cd> >> <title>Empire Burlesque</title> >> </cd> >> </catalog> >> >> XSL: >> <?xml version="1.0" encoding="ISO-8859-1"?> >> <!-- Edited by XMLSpy. --> >> <xsl:stylesheet version="1.0" >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> >> <xsl:template match="/"> >> <xsl:apply-templates/> >> </xsl:template> >> >> <xsl:template match="cd"> >> <newCD> >> <xsl:value-of select="."/> >> </newCD> >> </xsl:template> >> </xsl:stylesheet> >> >> >> Needed Output: >> <newCD> >> <title>Empire Burlesque</title> >> </newCD> >> >> Produced output: >> Empire Burlesque >> > Sudheshna, > I'm not sure what 2 XML input documents you wanted to traverse... I only > see one. > But you can get the output you're looking for by changing the last > template to: > > <xsl:template match="cd"> > <newCD> > <xsl:copy-of select="*"/> > </newCD> > </xsl:template> > > This is because <xsl:value-of> gets the text value of a nodeset, whereas > <xsl:copy-of /> copies each node and its descendants. > > Lars
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xml elements as output af, sudheshna iyer | Thread | [xsl] Free Boredom Relief ..., Gannon Dick |
Re: [xsl] xml elements as output af, sudheshna iyer | Date | Re: [xsl] How to implement a sequen, Mukul Gandhi |
Month |