[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Help with some XPATH questions
Michael, Well your suggestions helped me get rid of the error messages but all I get is a count of 13 items and none of the rest of the xml is filled out ... not sure why. Your explanation helped but now I am not sure why I am not getting any of the other parts into the xml document. Do you have any other suggestions as to what i could do... Thanks Vince On Thursday, July 28, 2005, at 02:19PM, Michael Kay <mike@xxxxxxxxxxxx> wrote: >> >> 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
|
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
|