Serially referring to elements in multiple files
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 3
- Joined: Mon Aug 12, 2013 6:39 pm
Serially referring to elements in multiple files
Hello all,
I am trying to create an XSLT stylesheet in order to convert XML information from multiple files. I have used the collection function to group the files, but my problem is more complex:
I have two sets of files: one directory includes xml HEADERs, the other directory the xml TEXTs of the same documents. The TEXTs are grouped by the collection function and I extract the elements I require from it. In addition, I need to extract elements (title and date) from the parallel header file (which have the same name and a common ID element, only .hdr extension). I tried this way, which as I suspected did not work:
any ideas how else I could solve this?
Many thanks,
Sinai
I am trying to create an XSLT stylesheet in order to convert XML information from multiple files. I have used the collection function to group the files, but my problem is more complex:
I have two sets of files: one directory includes xml HEADERs, the other directory the xml TEXTs of the same documents. The TEXTs are grouped by the collection function and I extract the elements I require from it. In addition, I need to extract elements (title and date) from the parallel header file (which have the same name and a common ID element, only .hdr extension). I tried this way, which as I suspected did not work:
Code: Select all
<xsl:variable name="X" select="collection('file:/.../?select=*.xml;recurse=yes')//TEXT"/>
<xsl:for-each select="$X">
<tr>
<xsl:variable name="headerfile" select= "self::IDG/@ID"> </xsl:variable>
<td><xsl:value-of select="$headerfile"/></td>
<td><xsl:value-of select="doc('file:/.../$headerfile.hdr')//TITLESTMT/TITLE"/></td>
<td><xsl:value-of select="doc('file:/...//$headerfile.hdr')//SOURCEDESC//DATE"/></td>
<td><xsl:value-of select="TEXT/FRONT"/></td>
<td><xsl:value-of select="TEXT/BACK"/></td>
<td><xsl:value-of select="TEXT/BODY"/></td>
Many thanks,
Sinai
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Serially referring to elements in multiple files
Hi,
The problem is you're not referring the headerfile variable correctly. This is not a macro, it won't be expanded if you refer it in the middle of a string. Try using the concat function when concatenating the file URI:
http://www.w3schools.com/xpath/xpath_fu ... asp#string
E.g.
Regards,
Adrian
The problem is you're not referring the headerfile variable correctly. This is not a macro, it won't be expanded if you refer it in the middle of a string. Try using the concat function when concatenating the file URI:
http://www.w3schools.com/xpath/xpath_fu ... asp#string
E.g.
Code: Select all
doc(concat('file:/.../’, $headerfile, '.hdr'))...
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: 3
- Joined: Mon Aug 12, 2013 6:39 pm
Re: Serially referring to elements in multiple files

FODC0002: I/O error reported by XML parser processing file:/Users/Sinai/Dropbox/EEBO-TCP//.hdr: /Users/Sinai/Dropbox/EEBO-TCP/.hdr (No such file or directory)
it seems to have ignored the $headerfile variable all together. perhaps concatenation doesn't enable to include variables?
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Serially referring to elements in multiple files
Hi,
It's not ignoring it, but it's probably empty.
What value do you see in the output between the td tags (the xsl:value-of seen above)?
If you see just <td></td>, then headerfile variable is empty, so you should check if the XPath (self::IDG/@ID) matches something on your input XML file in that context.
If you never get to see the output use: <xsl:message select="$headerfile"/> and you'll see the value in the Messages panel in Oxygen.
You can also use the debugger in Oxygen for such issues (Window > Open perspective > XSLT Debugger).
Regards,
Adrian
It's not ignoring it, but it's probably empty.
Code: Select all
<xsl:variable name="headerfile" select= "self::IDG/@ID"> </xsl:variable>
<td><xsl:value-of select="$headerfile"/></td>
If you see just <td></td>, then headerfile variable is empty, so you should check if the XPath (self::IDG/@ID) matches something on your input XML file in that context.
If you never get to see the output use: <xsl:message select="$headerfile"/> and you'll see the value in the Messages panel in Oxygen.
You can also use the debugger in Oxygen for such issues (Window > Open perspective > XSLT Debugger).
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