Jump to content

Insert Copy with variable


Loriot

Recommended Posts

Hi all, sorry for being such a massiv questioner right now but I got one more problem and maybe I get from you one more solution. I have a stylesheet that transforms some xml data and inserts at a certain position another xml file content. Looks like that in the place:

 <xsl:copy-of select="."/>		<xsl:copy-of select="document('SomeName.xml')"/>

Now I would like to replace the konkret filename with a variable så that i can fetch the filename from the data in the transformed main.xml I tried that way, but it didn't work out:

<xsl:variable name="Somename" select="FilenameValue"/> <xsl:copy-of select="."/>  <xsl:copy-of select="document('$SomeName')"/></xsl:variable>

Link to comment
Share on other sites

I generally avoid calling trivial issues "too easy", but man... this IS too easy!By using quotes to enclose an argument in function, or in the place of a node-set for that matter, you indicate that what you are typing is a litteral string. All other data types, among which is node-set, must be written without quotes.Second, variable names are case sencetive, but that's just a detail.

<xsl:variable name="Somename" select="FilenameValue"/><xsl:copy-of select="."/>  <xsl:copy-of select="document($Somename)"/></xsl:variable>

Is equivalent of

<xsl:copy-of select="."/>  <xsl:copy-of select="document(FilenameValue)"/></xsl:variable>

If FilenameValue is SomeName.xml in the actual node-set, then

<xsl:copy-of select="."/>  <xsl:copy-of select="document(FilenameValue)"/></xsl:variable>

becomes equivalent of

<xsl:copy-of select="."/>  <xsl:copy-of select="document('SomeName.xml')"/></xsl:variable>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...