Problem using variable to load document
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 1
- Joined: Tue Mar 02, 2010 11:34 am
Problem using variable to load document
Hi!
I wish to load code from a document, and I wish to store the file name in a variable.
For testing, I use a hardcoded file name, and to test it I also print it using value-of, as shown below.
<xsl:variable name="filename" select="'file.xml'" />
<xsl:value-of select="$filename" />
Note the single quotes I added in line one here, otherwise _nothing would print_ using value-of.
Then, to load the code:
<xsl:copy-of select="document($filename)" />
NO code is loaded here, I get a blank response. However, the following DOES work:
<xsl:copy-of select="document('file.xml')" />
I have tried so many combinations of quotes that I do not know if this is the problem, thought it seems likely. Please help.
Full code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="1.0"
xmlns:xalan="http://xml.apache.org/xslt">
<xsl:template match="/">
<xsl:variable name="filename" select="'file.xml'" />
<xsl:value-of select="$filename" />
<xsl:copy-of select="document($filename)" />
</xsl:template>
</xsl:stylesheet>
Please help me
Bendik
I wish to load code from a document, and I wish to store the file name in a variable.
For testing, I use a hardcoded file name, and to test it I also print it using value-of, as shown below.
<xsl:variable name="filename" select="'file.xml'" />
<xsl:value-of select="$filename" />
Note the single quotes I added in line one here, otherwise _nothing would print_ using value-of.
Then, to load the code:
<xsl:copy-of select="document($filename)" />
NO code is loaded here, I get a blank response. However, the following DOES work:
<xsl:copy-of select="document('file.xml')" />
I have tried so many combinations of quotes that I do not know if this is the problem, thought it seems likely. Please help.
Full code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="1.0"
xmlns:xalan="http://xml.apache.org/xslt">
<xsl:template match="/">
<xsl:variable name="filename" select="'file.xml'" />
<xsl:value-of select="$filename" />
<xsl:copy-of select="document($filename)" />
</xsl:template>
</xsl:stylesheet>
Please help me

Bendik
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Problem using variable to load document
Hi,
I cannot reproduce any issue with the code you included. Please make sure you have the file.xml file in the same folder as the stylesheet.
Best Regards,
George
I cannot reproduce any issue with the code you included. Please make sure you have the file.xml file in the same folder as the stylesheet.
Best Regards,
George
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service