Can you have XSL variables in the document() function?
This works just fine:
<xsl:variable
name="issue_info_file"
select="document('/issues/2010/12/08/info.xml')
/page-components/issue-metadata-component/title"/>
But this does not:
<xsl:variable
name="issue_info_file" 开发者_开发百科
select="string(concat($full_issue_path,'/info.xml'))"/>
<xsl:variable
name="issue_title"
select="document($issue_info_file)
/page-components/issue-metadata-component/title"/>
Does anyone if this is even allowed in XSLT? If not, does anyone recommend a solution for opening files with a dynamic variable?
I do not know if this issue is still open, but there does not seem to be an answer. I have this code working in my XSL file.
<xsl:variable name="docRoot">../sitemap/</xsl:variable>
<xsl:variable name="fullDocRoot" select="string(concat($docRoot,'sitemap.xml'))"/>
<xsl:for-each select="document($fullDocRoot)/root/sitemap/loc">
Hope that helps someone.
Can you have XSL variables in the document() function?
Yes.
Using variables as arguments of the document()
function is perfectly OK, provided the values of the arguments are of the type expected (such as a URI). Most probably the value of $full_issue_path
when concatenated with '/info.xml'
does not produce a valid URI or the correct URI.
You need to provide a complete example if you hope people to uncover your error.
精彩评论