Subject: RE: [xsl] extrat value from current node only. From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 30 Mar 2005 13:59:56 +0100 |
> Below are my xml & xls file: One of the first things to learn with XSLT is to get your fingers around the acronym... > > ________________ XML FILE _______________________ > > <?xml version="1.0" encoding="UTF-8" ?> > <items> > <item> > title 1 > <description>description 1</description> > </item> > <item> > title 2 > <description>description 2</description> > </item> > </items> > _________________________________________________ > Generally this isn't a good way of using XML mixed content (elements and text nodes as siblings of each other). The normal use of mixed content is for marking up parts of a continuous text, for example, <para>here is some <emph>important</emph> text</para>. If it doesn't make sense to concatenate the text with the adjacent elements, then the text should be in its own element. XSLT's value-of instruction assumes this design principle, because when you take the value-of the <item> element, it concatenates all the contained text. You can get at "title 1" separately from the description element by accessing the text nodes directly, but it's harder work. Michael Kay http://www.saxonica.com/ > ________________ XLS FILE _______________________ > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <xsl:template match="items"> > <xsl:apply-templates select="item"/> > </xsl:template> > > <xsl:template match="item"> > title:<xsl:value-of select="current()"/> > description:<xsl:value-of select="description"/> > </xsl:template> > > </xsl:stylesheet> > ___________________________________________________ > > I don't get > <?xml version="1.0" encoding="UTF-8"?> > title:title 11 > description:description 1 > > But ... > <?xml version="1.0" encoding="UTF-8"?> > title: > title 1 > description 1 > > description:description 1 > title: > title 2 > description 2 > > description:description 2 > > What changes do I have to make to my xls file to get the > output I want? > > Thank you for you help. > > Emmanuel
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] extrat value from current no, emmanuel ide | Thread | Re: [xsl] extrat value from curren, David Carlisle |
RE: [xsl] extrat value from curren, emmanuel ide | Date | RE: [xsl] extrat value from curren, emmanuel ide |
Month |