[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: cascading tags
Hi Andreas, > I would like to transform this file into: > > <p>there are two different levels of compliance for XML documents: > <p>the well-formednessof an XML document</p> > <p>the validityof an XML document</p> Where should the closing tag for the first p element go? Your code has bullet and number generation in. So I think you're actually after: <p> - there are two different levels of compliance for XML documents: <p>1. the well-formedness of an XML document</p> <p>2. the validity of an XML document</p> </p> Actually that isn't valid HTML (you can't have nested p elements), but you could always substitute the p elements for div elements if you need to. > If I use the following transformation codes > > <xsl:template match="bulletlist/item"> > <p><xsl:text>- </xsl:text> > <xsl:apply-templates/></p> > </xsl:template> > > <xsl:template match="numberedlist/item"> > <p><xsl:number value="position()" format="1. "/><xsl:value-of > select="text()" /></p> > <xsl:apply-templates/> > </xsl:template> > > I get > > <p>- there are two different levels of compliance for XML documents: > <p>1. the </p>the well-formedness of an XML document > <p>2. the </p>the validity of an XML document</p> If that's what you get, then you have some extra elements in your source document, within the numberedlist/item elements, that you haven't shown us. Something like: <item>the <kwd>well-formedness</kwd> of an XML document</item> When you say <xsl:value-of select="text()" /> then the processor gives you the value of the *first* text node child of the current (item) element, which is the 'the ' before the kwd element in the above. When you apply templates (after the p element that you generate) then you apply templates to all the children of the current (item) element, so you get the 'the ' repeated, along with the result of applying templates to the rest of the content of the item element. The template that you want for the numberedlist item follows the same model as the one you have for the bulletlist/item - create a p element and inside it put the number, followed by the result of applying templates to the content of the item: <xsl:template match="numberedlist/item"> <p> <xsl:number value="position()" format="1. " /> <xsl:apply-templates /> </p> </xsl:template> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|