Subject: RE: [xsl] Help with some XPATH questions From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 28 Jul 2005 22:18:44 +0100 |
> So far what I have is > > <RESULTSET> > <xsl:attribute name="FOUND"> > <xsl:value-of > select="count(//LayoutCatalog/Layout)"/> > </xsl:attribute> > <xsl:apply-templates > select="//LayoutCatalog/Layout/descendant::Object[@type='text']"/> > </RESULTSET> > > > I thought that this would work but it does not... this is the > error I get: > > Description: E Error in expression > //LayoutCatalog/Layout/descendant::Object[@type='text']: Axis > in pattern must be child or attribute It's a bad error message because it says first that it's an error in an expression and then that it's an error in a pattern, and expressions and patterns are quite different things. But it's patterns that don't allow axes other than child or attribute, so that's almost certainly what it's referring to. The select attribute of apply-templates is not a pattern, it's an expression. Your error is probably that you have used a similar construct in an <xsl:template match="XXX"> context, where it is not allowed. In a match pattern you can't write A/descendant::B, but you can write A//B which usually means the same thing. (The cases where it doesn't are where B is followed by a numeric predicate). > > I guess what I don't understand this error - and I also don't > really understand the role of > > "<xsl:attribute name="FOUND">" Your code snippet creates a RESULTSET element, with a FOUND attribute whose value is the number of //LayoutCatalog/Layout elements in the source document, with the content of the element being computed by the template that matches the selected Object elements. You could also have written this as: <RESULTSET FOUND="{count(//LayoutCatalog/Layout)}"> <xsl:apply-templates select="//LayoutCatalog/Layout//Object[@type='text']"/> </RESULTSET> Michael Kay
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Help with some XPATH question, Vincenzo Menanno | Thread | RE: [xsl] Help with some XPATH ques, Vincenzo Menanno |
[xsl] Help with some XPATH question, Vincenzo Menanno | Date | RE: [xsl] is there a String indexOf, Michael Kay |
Month |