Subject: [xsl] How to process elements with in elements... From: "Mohammed Rahman" <mrahman@xxxxxxxxxxxx> Date: Fri, 1 Jun 2001 11:56:07 -0700 |
Hi all, I have an xml look like this: <?xml version="1.0" ?> <articles> <article> <title> Title One </title> <section sid="1"> <text tid="1.1"> aaa1 </text> <allAtr> <atr1> a-atr1 </atr1> <atr2> a-atr2 </atr2> </allAtr> <text tid ="1.2"> aaa2 </text> <allAtr> <atr1> x-art1 </atr1> <atr2> x-atr2 </atr2> </allAtr> <section sid="1.1"> <text tid="1.1.1"> bbb </text> <allAtr> <atr1> b-art1 </atr1> <atr2> b-art2 </atr2> </allAtr> <text tid="1.1.2"> ccc </text> <allAtr> <atr1> c-atr1 </atr1> <atr2> c-atr2 </atr2> </allAtr> </section> <section sid="2"> <text tid="2.1"> ddd </text> <allAtr> <atr1> d-atr1 </atr1> <atr2> d-atr2 </atr2> </allAtr> ..... .... </section> </section> </article> </articles> The processing xsl look like this: <?xml version="1.0" encoding='ISO-8859-1' ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output cdata-section-elements="text"/> <xsl:template match="articles" > <xsl:apply-templates /> </xsl:template> <xsl:template match="article" > <articles> <xsl:attribute name="feedSource"> <xsl:value-of select="'ModuleOne'" /> </xsl:attribute> <xsl:attribute name="folderName"> <xsl:value-of select="'MyFolder'" /> </xsl:attribute> <xsl:attribute name="textInCData"> <xsl:value-of select="'true'" /> </xsl:attribute> <xsl:apply-templates select="section"/> </articles> </xsl:template> <xsl:template match="section" > <article> <title> <xsl:value-of select="./allAtr/atr1" /> </title> <xsl:text> </xsl:text> <displayableName> <xsl:value-of select="./allAtr/atr2" /> </displayableName> <xsl:text> </xsl:text> <text> <xsl:text disable-output-escaping="yes"><p></xsl:text> <xsl:apply-templates select="text/." /> <xsl:text disable-output-escaping="yes"></p></xsl:text> <xsl:text disable-output-escaping="yes"><p></xsl:text> </text> <xsl:text> </xsl:text> <xsl:text> </xsl:text> <xsl:apply-templates select="section"/> </article> </xsl:template> </xsl:stylesheet> The result I get is: <?xml version="1.0" encoding="utf-8"?> <articles feedSource="ModuleOne" folderName="MyFolder" textInCData="true"> <article> <title>a-atr1</title> <displayableName>a-atr2</displayableName> <text> <![CDATA[<p> aaa1 aaa2 </p><p>]]> </text> <article> <title>b-art1</title> <displayableName>b-art2</displayableName> <text> <![CDATA[<p> bbb ccc </p><p>]]> </text> </article> <article> <title>d-atr1</title> <displayableName>d-atr2</displayableName> <text> <![CDATA[<p> ddd </p><p>]]> </text> </article> </article> </articles> ..... But I want my result to be: <?xml version="1.0" encoding="utf-8"?> <articles feedSource="ModuleOne" folderName="MyFolder" textInCData="true"> <article> <title>a-atr1</title> <displayableName>a-atr2</displayableName> <text> <![CDATA[<p> aaa1 </p><p>]]> </text> </article> <article> <title>x-atr1</title> <displayableName>x-atr2</displayableName> <text> <![CDATA[<p> aaa2 </p><p>]]> </text> </article> ----- rest of the article tags ----- </articles> Please help!! XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSL to Sort XML Doc retur, Xiaocun Xu | Thread | RE: [xsl] How to process elements w, Tim Watts |
Re: [xsl] XSL to Sort XML Doc retur, Xiaocun Xu | Date | Re: [xsl] Book on XSP ?, Oskar Werewka |
Month |