Subject: RE: [xsl] Problem with Xpath From: ms <mina_hurray@xxxxxxxxx> Date: Wed, 13 Dec 2006 11:45:34 -0800 (PST) |
Thank you the .//info worked. But I guess I have a new problem now, since there is some styling to format these levels as 1, 2, 3 etc, now if the second<l1> tag matched then the numbering starts with 2. instead of 1. Is there any way to start this numebring at 1 instead of 2 so that even in between if there are levels that have to be missed the numbering stays as 1,2 , 3 and not 2, 5, ,6 etc. Please let me know. --- cknell@xxxxxxxxxx wrote: > Your example XML file does not contain elements with > the local names "company" and "product". Your XSLT > file is looking for them. Naturally it won't find > them, so the transformation will fail. > > This: <xsl:when test="//info"> > and this: <xsl:if test="//info/company=$company and > //info/product=$product"> > > are telling your stylesheet to start looking at the > root for elements matching the test criteria. > > Is that what you want? Or, do you want to look for > "info" elements that are descendants of the "l1" > element? > > Since the latter makes sense to me and the former > does not, maybe the XPath expression you are looking > for is > > <xsl:when test=".//info"> > and <xsl:if test=".//info/company=$company and > .//info/product=$product"> > > > N.B., there is a period character before the > double-slash. That tells your stylesheet to start at > the context node (<l1>, in this case) and not at the > document root. > > Get the element names correct and try these XPath > expressions, and get back to us if you are still > having a problem. > > -- > Charles Knell > cknell@xxxxxxxxxx - email > > > > -----Original Message----- > From: ms <mina_hurray@xxxxxxxxx> > Sent: Wed, 13 Dec 2006 10:39:01 -0800 (PST) > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Problem with Xpath > > Hi all: > > I am having issues with Xpath. > > My xml looks like this: > > <root> > > <l1> > <text> > <para>First level</para> > </text> > <info> > <comp>Kmart</comp> > <prod>Shoes</prod> > </info> > <l2> > <text> > <para>Second level .</para> > </text> > </l2> > </l1> > <l1> > <text> > <para>Second level</para> > <info> > <comp>Kmart</comp> > <prod>Shoes</prod> > </info> > </text> > </l1> > <l1> > <text> > <para>Third level</para> > <info> > <comp>Target</comp> > <prod>Pen</prod> > </info> > </text> > </l1> > </root> > > Now, I have logic in my style sheet which says that > only if element <l1> contains element <info>, then > if <comp> and <prod> values match the values being > passed to the style sheet through two other > parameters > <company> and <product> , then display l1 , > otherwise > do not display l1. > > The XSLT is : > > > <xsl:template match="l1"> > <xsl:choose> > <xsl:when test="//info"> > <xsl:if test="//info/company=$company and > //info/product=$product"> > <fo:list-block> > <fo:list-item> > <fo:list-item-label> > <fo:block> > <xsl:number format="1"/> > </fo:block> > </fo:list-item-label> > <fo:list-item-body> > <fo:block> > <xsl:apply-templates/> > </fo:block> > </fo:list-item-body> > </fo:list-item> > </fo:list-block> > </xsl:if> > </xsl:when> > <xsl:otherwise> > <!-- Do something else--> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > So, if I have passed $company="KMart" and > $product="Shoes" on the style sheet, then the > expected > output is: > > 1 First > 2 Second > > Instead, it matches only the company and product for > the first level and stops there. Can you please tell > me what is wrong with the xpath to company and > product > on the style sheet? > > Thank you in advance for your help. > > > > > > ____________________________________________________________________________________ > Do you Yahoo!? > Everyone is raving about the all-new Yahoo! Mail > beta. > http://new.mail.yahoo.com > > ____________________________________________________________________________________ Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Problem with Xpath, cknell | Thread | RE: RE: [xsl] Problem with Xpath, cknell |
RE: Re: [xsl] Option mystery, cknell | Date | Re: [xsl] Option mystery, CyberSpace Industrie |
Month |