Dill
Dill

Reputation: 2025

access input document in template that matches a node loaded by doc()

When applying a template to nodes that are loaded by doc(), how can I access the orignial input document in that template? Is there another way than adding a parameter like this?

<xsl:apply-templates select="doc('snippets.xml')//snippet">
    <xsl:with-param name="input-document" select="/" />
</xsl:apply-templates>

Upvotes: 0

Views: 55

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167706

You can have a global variable e.g.

<xsl:variable name="primary-input" select="/"/>

and then use $primary-input where needed. The name of the variable is up to you.

Upvotes: 1

Related Questions