xsl-list
[Top] [All Lists]

RE: Using id() when id and idref are in 2 different files

2004-12-13 05:20:22
Thanks! Now it works!

If your documents are
<xsl:value-of name="doc1" select="document('1.xml')"/>

I guess this should have been xsl:variable rather than xsl:value-of?

<xsl:variable name="x" select="@ref"/>
<xsl:for-each select="$doc1|$doc2|$doc3">
  <xsl:apply-templates select="id($x)"/>
</xsl:for-each>

I have only 1 document but I'd imagine that the purpose of xsl:for-each here
is to set the context node?

Now I have the values all bunched together and unformatted. So I changed
apply-templates to value-of and tried to use another for-each loop for each
value but it doesn't seem to like me nesting it in the other loop. I get
errors about the otherwise statement they are all inside. XML Parsing Error:
mismatched tag. Expected: </xsl:otherwise>.

<xsl:template match="move">
<p>
  <em>
    <xsl:choose>
      <xsl:when test="(@type = 'Exit') and not (@who)">
        Exeunt
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="@type" />: 
        <xsl:variable name="cast" select="document('front.xml')" />
        <xsl:variable name="who" select="@who" />
        <xsl:for-each select="$cast">
          <xsl:for-each select="id($who)" />
            <xsl:value-of select="id($who)" />, 
          </xsl:for-each>
        </xsl:for-each>
      </xsl:otherwise>
    </xsl:choose>
  </em>
</p>
</xsl:template>

Have I lost the plot sat at home with my cold and newbie brain? Or is there
an alternative to setting the context instead of for-each? I guess this has
taken up a lot of emails today for everyone and if that is the case please
feel free to point me with a suggested search term to use with the archives
or Google.

Many thanks to everyone that has replied so far.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--