RE: [xsl] Nesting <xsl:value-of> tags

Subject: RE: [xsl] Nesting <xsl:value-of> tags
From: "Roger Glover" <glover_roger@xxxxxxxxx>
Date: Mon, 3 Feb 2003 15:27:44 -0600
Zvolensky, Thomas J {PGL~Nutley} wrote:

> I have an xsl stylesheet that reads an xml document and selects
> all nodes having a specific non-blank attribute.
>
> The skeleton of my tags is as follows:
>
>
> <xsl:for-each select="//*[./@filename != '']">
> .
> .
> <xsl:value-of
> select="document('ShareWebUsers.xml')//person[id=<xsl:value-of
> select="../@ownedby"/>]/ntname"/>
> .
> .
> </xsl:for-each>
>
>
> In the middle, I have an <xsl:value-of> tag that reads a value
> from another document (ShareWebUsers.xml) and returns the value
> of the <ntname> tag based on the value of "ownedby" attribute of
> the current node.
>
> When I use the code as described above, XMLSPY informs me that my
> XML is not well-formed.
>
> Is it possible to nest <xsl: value-of> tags like this?

No, XSLT does not allow it, but even more fundamentally, it is not
well-formed XML.


> If not,
> is there another way to look up the value of <ntname> from the
> other document?

Since you are confused on this issue, it is unclear to me what you intend
".." to mean:
    o   parent of the "current node" ("current" is node selected by
        "//*[./@filename != '']")
    o   parent of the "context node" ("context" is node selected by
        "document('ShareWebUsers.xml')//person")

If you want the current node's parent, use this:

    <xsl:value-of
    select =
    "document('ShareWebUsers.xml')//person[id =
current()/../@ownedby"/>]/ntname"
    />

If you want the context node's parent, use this:

    <xsl:value-of
    select =
    "document('ShareWebUsers.xml')//person[id = ../@ownedby"/>]/ntname"
    />

I hope this helps!

-- Roger Glover
   glover_roger@xxxxxxxxx



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


Current Thread