calling the document() function from within a for-each loop
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 269
- Joined: Sat Jul 10, 2010 4:03 pm
calling the document() function from within a for-each loop
I need to process multiple documents, I have a list of filenames and am using a for-each loop to process the list
When inside the for-each, I can't use something like
because document-uri(/) means nothing in the context of a for-each loop
I tried a relative path from the folder of the xslt stylesheet
but it returns an empty-sequence()
I gave it the full path and it works
I can't use the full path as that path doesn't exist on the production server.
How can I get to the documents using a relative path?
When inside the for-each, I can't use something like
Code: Select all
document(resolve-uri('build.log', document-uri(/)))
I tried a relative path from the folder of the xslt stylesheet
Code: Select all
document('file:/../../working_files/build.log')
I gave it the full path and it works
Code: Select all
document( 'file:///home/scott/workspace/mbel-work/working_files/build.log')
How can I get to the documents using a relative path?
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: calling the document() function from within a for-each loop
Hi,
The root(/) of the input XML document is still available in a for-each loop. So, I'm not sure why you say that:Where build.log contains just "<a/>".
My results are:
Regards,
Adrian
The root(/) of the input XML document is still available in a for-each loop. So, I'm not sure why you say that:
I've tried the following xsl:messages inside a for-each loop and they worked fine:document-uri(/) means nothing in the context of a for-each loop
Code: Select all
<xsl:message select="'URI:', document-uri(/)"/>
<xsl:message select="'Resolved URI:', resolve-uri('build.log', document-uri(/))"/>
<xsl:message select="'Doc:', document(resolve-uri('build.log', document-uri(/)))"/>
My results are:
Code: Select all
[Saxon-PE] URI: file:/C:/Users/adrian/Desktop/Support/sample.xml
[Saxon-PE] Resolved URI: file:/C:/Users/adrian/Desktop/Support/build.log
[Saxon-PE] Doc:<a/>
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: calling the document() function from within a for-each loop
Hi again,
I had some doubts about more complicated for-each loops, so I've double checked and document-uri(/) changes as expected depending on the context from the for-each:
- if you have a for-each over a collection
e.g.
- if you have a for-each over a sequence of documents.
e.g.
So the question is, what kind of for-each are you using that's breaking this?
Regards,
Adrian
I had some doubts about more complicated for-each loops, so I've double checked and document-uri(/) changes as expected depending on the context from the for-each:
- if you have a for-each over a collection
e.g.
Code: Select all
<xsl:for-each select="collection('file:/C:/path/to/my/files/?select=*.xml;recurse=yes')">
e.g.
Code: Select all
<xsl:for-each select="document(('file:/C:/path/to/my/file.xml', 'file:/C:/other/path/to/my/other/file.xml'))">
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ 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