[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem with id(@attrib)

Subject: Re: Problem with id(@attrib)
From: Keith Visco <kvisco@xxxxxxxxx>
Date: Thu, 18 Mar 1999 14:25:02 -0500
keith blanchette
Without really looking into it, I believe the two should work the same

select="//id(@product)/@name" 

should select the name attribute of all descendants of the root element
with the given id. Since there can be only one element with any given ID
it should only select one element, or no elements if no element is
found.

select="id(@product)/@name" 

should select the name attribute of the element with the given id.

so these should really be the same.

There is probably a bug in XSL:P that is resulting in all three nodes
having been selected when using //. I will look into this and provide a
fix if necessary.

--Keith


"Blanchette, Larry" wrote:
> 
> John,
> 
> using:
>         select="id(@product)/@name"/>
> instead of
>         select="//id(@product)/@name"/>
> seems to to the trick under xslp
> 
> I guess the logic is // selects descendents from instead of chidlren
> from. If id(@product) evals to the product element it would be the
> same as //product/@name.
> 
> larry
> 
> -----Original Message-----
> From: John_Velonis@xxxxxxxxxxxx [mailto:John_Velonis@xxxxxxxxxxxx]
> Sent: Thursday, March 18, 1999 9:28 AM
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: Problem with id(@attrib)
> 
> 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
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.