%20 characters in //xsl:result-document/@href
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 7
- Joined: Wed Jul 26, 2006 11:24 am
- Location: Zurich/Switzerland
%20 characters in //xsl:result-document/@href
I have a multiple-include master stylesheet with a bunch of xsl:result-document instructions writing a set of xml files to a basepath specified in a global variable.
<xsl:variable name="BASEPATH" select="'file:/C:/Dokumente%20und Einstellungen/myName/Eigene%20Dateien/myHTMLOutput'"/>
The out href for the xsl:result-document statement is later calculated in a local variable select inside a for-each loop, eg
<xsl:for-each select="/pages">
<xsl:variable name="myHref" as="xs:string" select="concat($BASEPATH,'/',@ID,'.html')"/>
<xsl:result-document href="{$myHref}" method="html">
[...]
</xsl:result-document>
</xsl:for-each>
The transformation from Oxygen 7.2. (selection: Saxon 8B) works only if $BASEPATH doesn't contain any space chars (%20). When I run the xslt debugger for the scenario, however, the output is as expected. The transformation also works, if I invoke [OxygenDir]/lib/Saxon8.jar from the commandline.
<xsl:variable name="BASEPATH" select="'file:/C:/Dokumente%20und Einstellungen/myName/Eigene%20Dateien/myHTMLOutput'"/>
The out href for the xsl:result-document statement is later calculated in a local variable select inside a for-each loop, eg
<xsl:for-each select="/pages">
<xsl:variable name="myHref" as="xs:string" select="concat($BASEPATH,'/',@ID,'.html')"/>
<xsl:result-document href="{$myHref}" method="html">
[...]
</xsl:result-document>
</xsl:for-each>
The transformation from Oxygen 7.2. (selection: Saxon 8B) works only if $BASEPATH doesn't contain any space chars (%20). When I run the xslt debugger for the scenario, however, the output is as expected. The transformation also works, if I invoke [OxygenDir]/lib/Saxon8.jar from the commandline.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: %20 characters in //xsl:result-document/@href
Post by sorin_ristache »
Hello,
Regards,
Sorin
Is there an error reported ? An output file which should be created by xsl:result-document is not created ? Please post small sample files (XML source and XSLT 2.0 stylesheet) showing that the transformation does not work or send files for reproducing the problem to support at oxygenxml dot com.shuphi wrote:The transformation from Oxygen 7.2. (selection: Saxon 8B) works only if $BASEPATH doesn't contain any space chars (%20).
Regards,
Sorin
-
- Posts: 7
- Joined: Wed Jul 26, 2006 11:24 am
- Location: Zurich/Switzerland
Error: Premature End of File
After various tests I came to the conclusion that the errors occurring with the
- doc($myString) function
- xsl:result-document[matches(@href eq $myString])
are not reproducable consistently, if $myString contains %20 or - (dash) chars in directory names.
The error occurs just sometimes, sometimes it doesn't
However, oxygen seems to have a general problem in handling the collection() function (When transforming with Saxon 8B, I couldn't verify the scenario with Saxon8SA).
Example:
Something like the example below will ALWAYS return a "premature end of file" error
<xsl:variable name="myPath" select="'file:/C:/anyOldPath/To/My/XMLFiles'"/>
<root>
<xsl:for-each select="collection($myPath)/myElement">
<!-- do anything -->
</xsl:for-each>
</root>
- doc($myString) function
- xsl:result-document[matches(@href eq $myString])
are not reproducable consistently, if $myString contains %20 or - (dash) chars in directory names.
The error occurs just sometimes, sometimes it doesn't
However, oxygen seems to have a general problem in handling the collection() function (When transforming with Saxon 8B, I couldn't verify the scenario with Saxon8SA).
Example:
Something like the example below will ALWAYS return a "premature end of file" error
<xsl:variable name="myPath" select="'file:/C:/anyOldPath/To/My/XMLFiles'"/>
<root>
<xsl:for-each select="collection($myPath)/myElement">
<!-- do anything -->
</xsl:for-each>
</root>
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Error: Premature End of File
Post by sorin_ristache »
Hello,
Regards,
Sorin
A scenario for reproducing it will be helpful.shuphi wrote:The error occurs just sometimes, sometimes it doesn't
Please post sample files for reproducing the error. Also specify the paths for all the files.shuphi wrote:Something like the example below will ALWAYS return a "premature end of file" error
Regards,
Sorin
-
- Posts: 7
- Joined: Wed Jul 26, 2006 11:24 am
- Location: Zurich/Switzerland
examples
I have to revise my conclusions.
The following scenario should collect the contents of
C:\temp\my-Directory\xml, and for-each element 'doc' encountered in the collection write a result-document to C:\temp\my-Directory\outfiles\out{@id}.xml
1. Create the Directories C:\temp\my-Directory, C:\temp\my-Directory\xml, C:\temp\my-Directory\xsl,
----------------------------------------------------------------------------------------
2. Put the file input.xml to C:\temp\my-Directory
<!-- input.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<dummy/>
----------------------------------------------------------------------------------------
3. Put the files source1.xml, source2.xml, input.xml
to C:\temp\my-Directory
<!-- source1.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<doc id="101">
<header>
<title>my Title</title>
<text>my Text</text>
</header>
</doc>
<!-- source2.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<doc id="102">
<header>
<title>my Title</title>
<text>my Text</text>
</header>
</doc>
<!-- input.xml, this is the same dummy as above -->
<?xml version="1.0" encoding="UTF-8"?>
<dummy/>
----------------------------------------------------------------------------------------
4. Put the file transform.xsl to C:\temp\my-Directory\transform.xsl
<!-- transform.xsl -->
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:variable name="BASEPATH" as="xs:string" select="'file:/C:/temp/my-Directory'"/>
<xsl:variable name="SRCXML" as="xs:string" select="concat($BASEPATH,'/xml')"/>
<xsl:variable name="MYSOURCE" select="collection($SRCXML)"/>
<xsl:template match="/">
<xsl:for-each select="$MYSOURCE/doc">
<xsl:variable name="OUTPATH" select="concat($BASEPATH,'/outfiles/out',@id,'.xml')"/>
<xsl:result-document href="{$OUTPATH}" method="xml">
<root>
<xsl:copy-of select="header" copy-namespaces="no"/>
</root>
</xsl:result-document>
</xsl:for-each>
<done/>
</xsl:template>
</xsl:stylesheet>
----------------------------------------------------------------------------------------
5. Open C:\temp\my-Directory\input.xml with Oxygen and create a scenario to transform the file with C:\temp\my-Directory\xsl\transform.xsl
----------------------------------------------------------------------------------------
6. Run the transformation; this will work
----------------------------------------------------------------------------------------
7. Open C:\temp\my-Directory\xml\input.xml with Oxygen and create a scenario to transform the file with C:\temp\my-Directory\xsl\transform.xsl
----------------------------------------------------------------------------------------
8. Run this transformation; This will fail with error "premature end of file"
-----------------------------------------------------------------------------------------
Conclusion:
- Oxygen fails to handle collection($PATH), if the transformation input file is itself under the $PATH.
Note:
- If Saxon8B is run from the cmdline both scenarios will succeed
The following scenario should collect the contents of
C:\temp\my-Directory\xml, and for-each element 'doc' encountered in the collection write a result-document to C:\temp\my-Directory\outfiles\out{@id}.xml
1. Create the Directories C:\temp\my-Directory, C:\temp\my-Directory\xml, C:\temp\my-Directory\xsl,
----------------------------------------------------------------------------------------
2. Put the file input.xml to C:\temp\my-Directory
<!-- input.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<dummy/>
----------------------------------------------------------------------------------------
3. Put the files source1.xml, source2.xml, input.xml
to C:\temp\my-Directory
<!-- source1.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<doc id="101">
<header>
<title>my Title</title>
<text>my Text</text>
</header>
</doc>
<!-- source2.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<doc id="102">
<header>
<title>my Title</title>
<text>my Text</text>
</header>
</doc>
<!-- input.xml, this is the same dummy as above -->
<?xml version="1.0" encoding="UTF-8"?>
<dummy/>
----------------------------------------------------------------------------------------
4. Put the file transform.xsl to C:\temp\my-Directory\transform.xsl
<!-- transform.xsl -->
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:variable name="BASEPATH" as="xs:string" select="'file:/C:/temp/my-Directory'"/>
<xsl:variable name="SRCXML" as="xs:string" select="concat($BASEPATH,'/xml')"/>
<xsl:variable name="MYSOURCE" select="collection($SRCXML)"/>
<xsl:template match="/">
<xsl:for-each select="$MYSOURCE/doc">
<xsl:variable name="OUTPATH" select="concat($BASEPATH,'/outfiles/out',@id,'.xml')"/>
<xsl:result-document href="{$OUTPATH}" method="xml">
<root>
<xsl:copy-of select="header" copy-namespaces="no"/>
</root>
</xsl:result-document>
</xsl:for-each>
<done/>
</xsl:template>
</xsl:stylesheet>
----------------------------------------------------------------------------------------
5. Open C:\temp\my-Directory\input.xml with Oxygen and create a scenario to transform the file with C:\temp\my-Directory\xsl\transform.xsl
----------------------------------------------------------------------------------------
6. Run the transformation; this will work
----------------------------------------------------------------------------------------
7. Open C:\temp\my-Directory\xml\input.xml with Oxygen and create a scenario to transform the file with C:\temp\my-Directory\xsl\transform.xsl
----------------------------------------------------------------------------------------
8. Run this transformation; This will fail with error "premature end of file"
-----------------------------------------------------------------------------------------
Conclusion:
- Oxygen fails to handle collection($PATH), if the transformation input file is itself under the $PATH.
Note:
- If Saxon8B is run from the cmdline both scenarios will succeed
-
- Posts: 7
- Joined: Wed Jul 26, 2006 11:24 am
- Location: Zurich/Switzerland
downloadlink
to make it easier, all the files mentioned above can be downloaded from here:
http://www.pcs-ag.com/pcsdoc/my-Directory.zip
http://www.pcs-ag.com/pcsdoc/my-Directory.zip
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
Thank you for the files. We can reproduce the bug. We will let you know about the fix.
Regards,
Sorin
Thank you for the files. We can reproduce the bug. We will let you know about the fix.
Regards,
Sorin
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: examples
Post by sorin_ristache »
Hello,
- if you know a file pattern for the collection files use it in the collection() call:
- otherwise use the on-error param of the collection() function:
Regards,
Sorin
An output file is created at the beginning of the transformation and the collection() function as you call it (on all files of a directory) tries to collect it too. When the collection() function is evaluated this file is empty so parsing it as an XML file fails with the "Premature end of file" error. This file should not be included in the collection as it does not exist on disk when the transformation is started. In the next version of oXygen we will avoid including it in the collection. In the current version (7.2) you have two options to avoid the error:shuphi wrote:Oxygen fails to handle collection($PATH), if the transformation input file is itself under the $PATH.
- if you know a file pattern for the collection files use it in the collection() call:
Code: Select all
<xsl:variable name="MYSOURCE" select="collection(concat($SRCXML, '?select=*.xml'))"/>
Code: Select all
<xsl:variable name="MYSOURCE" select="collection(concat($SRCXML, '?on-error=ignore'))"/>
Sorin
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