[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Grouping multiple tags into one parent tag
At 2009-02-15 13:11 -0500, Chad Chelius wrote:
Thank you all for your responses. Ken this is exactly what I was trying to do! The only thing is, I am also using: Your transformation does not create any text nodes to be wrapped, it is creating only <p> element children. Again, I'm suspecting an example from you would be critically important to understand your problem. Perhaps you want the following? <field name="body"> <![CDATA[ <p>content here</p> <p>content here</p> <p>content here</p> ]]> </field> Then you want: <xsl:output method="xml" cdata-section-elements="field"/> <xsl:template match="body"> <xsl:if test="not(preceding-sibling::body)"> <field name="body"> <xsl:for-each select="../body"> <xsl:text><p></xsl:text> <xsl:apply-templates/> <xsl:text></p> </xsl:text> </xsl:for-each> </field> </xsl:if> </xsl:template> ... because you are asking the stylesheet to produce text, not elements ... the text just happens to look like elements when wrapped in a CDATA section. I hope the example below helps. . . . . . . . . Ken t:\ftemp>type chad.xml <test> <body>content here</body> <body>content there</body> <body>content everywhere</body> </test> t:\ftemp>xslt chad.xml chad.xsl <?xml version="1.0" encoding="utf-8"?> <field name="body"><![CDATA[<p>content here</p> <p>content there</p> <p>content everywhere</p> ]]></field> t:\ftemp>type chad.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" cdata-section-elements="field"/> <xsl:template match="body"> <xsl:if test="not(preceding-sibling::body)"> <field name="body"> <xsl:for-each select="../body"> <xsl:text><p></xsl:text> <xsl:apply-templates/> <xsl:text></p> </xsl:text> </xsl:for-each> </field> </xsl:if> </xsl:template> </xsl:stylesheet> t:\ftemp> -- Upcoming hands-on XSLT, UBL & code list hands-on training classes: Brussels, BE 2009-03; Prague, CZ 2009-03, http://www.xmlprague.cz Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|