XSLT which output non-xml text in XProc
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 22
- Joined: Tue Oct 17, 2017 5:05 pm
XSLT which output non-xml text in XProc
Post by serioadamo97 »
I have a XSLT to generate code
text.xsl:
And a XProc
test.xpl
When execute test.xpl, the error occured:
Engine name: Calabash XProc
Severity: error
Description: p:xslt returned non-XML result
Start location: 8:46
I read the document in w3c https://www.w3.org/TR/xproc/#c.xslt
It does not say that the output of p:xslt must be xml.
Is there any way to fix this issue ?
Thanks.
text.xsl:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template name="main">
// Code generated xxxxx
// .......
class Test
{
}
</xsl:template>
</xsl:stylesheet>
test.xpl
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
<p:output port="result" primary="false">
<p:pipe port="result" step="test"/>
</p:output>
<p:xslt name="test" template-name="main">
<p:input port="source">
<p:empty/>
</p:input>
<p:input port="stylesheet">
<p:document href="test.xsl"/>
</p:input>
<p:input port="parameters">
<p:empty/>
</p:input>
</p:xslt>
</p:declare-step>
Engine name: Calabash XProc
Severity: error
Description: p:xslt returned non-XML result
Start location: 8:46
I read the document in w3c https://www.w3.org/TR/xproc/#c.xslt
It does not say that the output of p:xslt must be xml.
Is there any way to fix this issue ?
Thanks.
Re: XSLT which output non-xml text in XProc
Hi,
I don't think there is a way to overcome this without wrapping your output text in an XML tag, you should read this part of the XProc specs:
https://www.w3.org/TR/xproc/#binary
I think that right now they are working on the XProc 3.0 standard which may have the support you want but I'm not sure.
There is an XProc users list if you want to ask around:
http://xproc.org/
Regards,
Radu
I don't think there is a way to overcome this without wrapping your output text in an XML tag, you should read this part of the XProc specs:
https://www.w3.org/TR/xproc/#binary
I think that right now they are working on the XProc 3.0 standard which may have the support you want but I'm not sure.
There is an XProc users list if you want to ask around:
http://xproc.org/
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: XSLT which output non-xml text in XProc
I know this is an old post, but if anybody comes across it (like me, the next time I forget how this works and google the error again), I thought I should clarify that you can store non-xml from xproc by using p:store, but, as Radu says, you must produce xml from the xslt step.
In this case, make sure that the output of your xslt does produce xml by wrapping the output in some dummy element, <root> or whatever.
Then in your p:store, use method="text'. The stored document will throw away that dummy root element. One advantage of outputting xml is that you can use logic in your xslt to set the xml:base on that root element and then store the resulting text file in that location. If you had just output a text file, there would be no xml:base to work with:
<!-- xslt step here -->
If you're producing other files using xsl:result-document you have to use p:store to get those files off the secondary port.
See also: https://stackoverflow.com/questions/133 ... -documents
Regards,
David
In this case, make sure that the output of your xslt does produce xml by wrapping the output in some dummy element, <root> or whatever.
Then in your p:store, use method="text'. The stored document will throw away that dummy root element. One advantage of outputting xml is that you can use logic in your xslt to set the xml:base on that root element and then store the resulting text file in that location. If you had just output a text file, there would be no xml:base to work with:
<!-- xslt step here -->
Code: Select all
<p:store encoding="utf-8" indent="true" method="text">
<p:input port="source">
<p:pipe port="result" step="some-xsl-step"/>
</p:input>
<p:with-option name="href" select="base-uri(/*)"/>
</p:store>
See also: https://stackoverflow.com/questions/133 ... -documents
Regards,
David
Return to “General XML Questions”
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