Subject: RE: [xsl] Nesting <xsl:value-of> tags From: "Zvolensky, Thomas J {PGL~Nutley}" <THOMAS_J.ZVOLENSKY@xxxxxxxxx> Date: Tue, 04 Feb 2003 15:05:20 -0500 |
Wendell, Thanks for your help. The code works - sort of. If the <id> corresponds to the first person in the ShareWebUsers.xml, it returns the correct value of the <ntname> tag. If the <id> is for the 2nd ... nth person, I get nothing. There is a sample of what ShareWebUsers.xml looks like: <?xml version="1.0" encoding="UTF-8"?> <directory> <person> <id>4763453</id> <ntname>zvolenst</ntname> </person> <person> <id>1580652</id> <ntname>watsonc</ntname> </person> <person> <id>3113434</id> <ntname>zabkas</ntname> </person> </directory> Any idea why I can't get the ntname back for 1580652 or 3113434? -----Original Message----- From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx] Sent: Monday, February 03, 2003 4:10 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Nesting <xsl:value-of> tags Hello Thomas, >Is it possible to nest <xsl: value-of> tags like this? No. > If not, is there another way to look up the value of <ntname> from the > other document? This is how I would do it: Outside your template, bind the other document to a variable: <xsl:variable name="lookupdoc" select="document('ShareWebUsers.xml')"/> Set up a key to retrieve persons by id element child: <xsl:key name="personsbyID" match="person" use="id"/> (In your code, you have "person[id=..." so I've said use="id"; change to @id if you're actually wanting an attribute not an element) Then inside your template: <xsl:for-each select="//*[./@filename != '']"> <xsl:variable name="ownedby" select="../@ownedby"/> <!-- binds the ownedby to a variable so we can get it after we change context --> <xsl:for-each select="$lookupdoc"> <!-- change context to lookup doc --> <xsl:value-of select="key('personsbyID',$ownedby)/ntname"/> </xsl:for-each> </xsl:for-each> If you wanted to skip the whole key thing you could simply do <xsl:value-of select="document('ShareWebUsers.xml')//person[id=$ownedby]"/>]/ntname"/> but that's relatively more expensive (since ShareWebUsers.xml will have to be traversed again and again, and maybe even parsed repeatedly depending on your processor). <xsl:value-of select="$lookupdoc//person[id=$ownedby]"/>]/ntname"/> may be somewhat better but is still costly compared to using the key. HTH-- Wendell ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Nesting <xsl:value-of> ta, Wendell Piez | Thread | RE: [xsl] Nesting <xsl:value-of> ta, Wendell Piez |
RE: [xsl] is XSLT 2.0 implementable, Elliotte Rusty Harol | Date | [xsl] xsl:output/@indent="yes" and , Gunther Schadow |
Month |