[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Problem with id(@attrib)
Thanks, that worked for both LotusXSL and XSL:P. I was under the mistaken impression that id() would only select children of the current node unless I explicitly started from the root node. (Hint to the spec authors...) -------------------------------------------------------------------------- Steve Dahl <sdahl@xxxxxxxxxxx> on 03/18/99 01:07:01 PM To: John Velonis@Hyperion cc: Subject: Re: Problem with id(@attrib) XSL:P is probably doing the right thing--the pattern you supplied means "get me any element whose ID is reachable from ANY product attribute in the document". This is because you start from the root rather than from the current node. See if this works any better: <xsl:value-of select="id(@product)/@name"/> John_Velonis@xxxxxxxxxxxx wrote: > Hi all, > > I'm trying to convert the following XML to HTML using XSL: > > <?xml version="1.0"?> > > <vendors> > > <org name="Organization 1"> > <builds product="p1"/> > <builds product="p2"/> > </org> > > <org name="Organization 2"> > <builds product="p3"/> > </org> > > <product id="p1" name="Product1"> > </product> > > <product id="p2" name="Product2"> > </product> > > <product id="p3" name="Product3"> > </product> > > </vendors> > > Here's my XSL stylesheet. I'm new to XSL, so it may be kind of klunky, > but according to the spec it looks like it should work: > > <?xml version="1.0"?> > > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/TR/WD-xsl" > xmlns="http://www.w3.org/TR/REC-html40" > result-ns=""> > > <xsl:id attribute="id"/> > > <xsl:template match="vendors"> > <HTML> > <BODY> > <H1>Organizations</H1> > <xsl:apply-templates select="org"/> > <HR/><H1>Products</H1> > <xsl:apply-templates select="product"/> > </BODY> > </HTML> > </xsl:template> > > <xsl:template match="org"> > <HR/><H2><xsl:value-of select="@name"/></H2> > <xsl:if test="builds"><H3>Products</H3><UL> > <xsl:apply-templates select="builds"/></UL></xsl:if> > </xsl:template> > > <xsl:template match="builds"> > <LI><A HREF="#{@product}"><xsl:value-of > select="//id(@product)/@name"/></A></LI> > </xsl:template> > > <xsl:template match="product"> > <HR/><H2><A NAME="#{@id}"><xsl:value-of select="@name"/></A></H2> > </xsl:template> > > </xsl:stylesheet> > > The problem I'm having is with the "//id(@product)/@name" selection in the > "builds" > template. LotusXSL returns nothing for this: > <A HREF="#p1"></A> > XSL:P does better, but it includes all three products, not just the one with the > specified id: > <A HREF="#p1">Product1Product2Product3</A> > > Is this valid usage? Is there some other way to do this? It seems like a > simple > task, but I haven't seen this exact situation in any examples. > > John Velonis > Hyperion Solutions > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list -- - Steve Dahl sdahl@xxxxxxxxxxx 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
|