Re: [xsl] 2 XML Files, 1 XSLt Output to HTML

Subject: Re: [xsl] 2 XML Files, 1 XSLt Output to HTML
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 18 Oct 2006 19:21:18 +0200
McDonald, Shaun wrote:
XSLT Version 1.0:
<xsl:template match="n1:share">
    <xsl:variable name="x" select="@item" />
    <xsl:variable name="xx" select="@loc" />
    <xsl:for-each select="document(@loc)">
      <xsl:value-of select="current()"/>
    </xsl:for-each>
 </xsl:template>

I want,
TARGET: doc2.xml:
<Oproc>
<Para>
<bold id="ao1">text1</bold>
<extRef id="getmaster" href="somedoc.html#idTitle1234"
reflocation="*" refmanual=""/>
</Para>


You are using <xsl:value-of> here. Surely that's not what you want. You don't want the *value* (which returns a string representation of the nodes in the select expression) but a *copy* of all the nodes. Change "value-of" to "copy-of" and you are done (it will copy comment nodes and processing instructions as well but not the opening xml declaration).

Another little thing, why the for-each? You can remove it and just use:
<xsl:copy-of select="document(@loc)" />

(it is only from xslt 2.0 that document(xx) function can be used on a sequence and will return multiple documents, in which case the for-each could make sense)

Cheers,

-- Abel Braaksma
  http://www.nuntia.com

Current Thread