xsl with replace function can't be compiled
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 24
- Joined: Wed Feb 13, 2013 9:54 am
xsl with replace function can't be compiled
Post by forummarcel »
Hello Everyone
I am creating an ant-script where i execute an xsl-statement that uses the following command (which is apparently not available in xslt1.0):
<xsl:value-of select="replace(., 'old', 'current')
Consequence: my ant script returns a fatal error, and says the stylesheet couldn't be compiled.
Is there a setting i am missing? Or is there an equivalent replace function which i could use for my purpose?
Thanks in adavance for any advise.
marcel
I am creating an ant-script where i execute an xsl-statement that uses the following command (which is apparently not available in xslt1.0):
<xsl:value-of select="replace(., 'old', 'current')
Consequence: my ant script returns a fatal error, and says the stylesheet couldn't be compiled.
Is there a setting i am missing? Or is there an equivalent replace function which i could use for my purpose?
Thanks in adavance for any advise.
marcel
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: xsl with replace function can't be compiled
Hi,
If you don't need to stick with XSL 1.0, you could run the transformation with Saxon9 (XSL 2.0 engine) from ANT:
Saxon - Running Saxon XSLT Transformations from Ant
There's also a discussion thread on stackoverflow that mentions a bug in ANT 1.8.1 that may require a workaround for this:
stackoverflow - How to execute XSLT 2.0 with ant?
Regards,
Adrian
If you don't need to stick with XSL 1.0, you could run the transformation with Saxon9 (XSL 2.0 engine) from ANT:
Saxon - Running Saxon XSLT Transformations from Ant
There's also a discussion thread on stackoverflow that mentions a bug in ANT 1.8.1 that may require a workaround for this:
stackoverflow - How to execute XSLT 2.0 with ant?
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
-
- Posts: 24
- Joined: Wed Feb 13, 2013 9:54 am
Re: xsl with replace function can't be compiled
Post by forummarcel »
hi adrian
i use the regular oxygen-ant setup, and i don't have ant installed seperately. could it be that i can't make this issue work because of that?
what i would prefer would be a xslt replacement function that replaces some characters with others within strings, that also works for xslt1.0?
I am not familiar with setting up java classes and parameters, sorry.
marcel
i use the regular oxygen-ant setup, and i don't have ant installed seperately. could it be that i can't make this issue work because of that?
what i would prefer would be a xslt replacement function that replaces some characters with others within strings, that also works for xslt1.0?
I am not familiar with setting up java classes and parameters, sorry.
marcel
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: xsl with replace function can't be compiled
Hi,
In that case, you could use this template:
stackoverflow - How do I do a str:replace in XSLT/XPATH 1.0?
Note that it's not a function, there are no user defined functions in vanilla XSL 1.0, you need EXSLT for that.
Regards,
Adrian
In that case, you could use this template:
stackoverflow - How do I do a str:replace in XSLT/XPATH 1.0?
Note that it's not a function, there are no user defined functions in vanilla XSL 1.0, you need EXSLT for that.
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
-
- Posts: 24
- Joined: Wed Feb 13, 2013 9:54 am
Re: xsl with replace function can't be compiled
Post by forummarcel »
thanks adrian for your reply, this helped, and my script is running properly now in xslt 1.0.
now i run into another problem: because i am testing my ant-script outside of the dita-ot-environment i cannot run even simple test-scripts from the oxygen-ant-scenario.
i already removed everything related to dita but still don't get a good result.
what parameters do i have to set that i can execute the ant-scenario independantly of the dita toolkit? Example:
now i run into another problem: because i am testing my ant-script outside of the dita-ot-environment i cannot run even simple test-scripts from the oxygen-ant-scenario.
i already removed everything related to dita but still don't get a good result.
what parameters do i have to set that i can execute the ant-scenario independantly of the dita toolkit? Example:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<project name="test-ant" basedir=".">
<description>test-ant</description>
<target name="replace_string">
<xslt in="input.ditamap" out="output.ditamap" style="filter_ditamap.xsl">
</xslt>
</target>
</project>
-
- Posts: 24
- Joined: Wed Feb 13, 2013 9:54 am
Re: xsl with replace function can't be compiled
Post by forummarcel »
just updating: in the meantime i am surcompassing the problem over an xslt-scenario. This one works fine. What i am not understanding, why the same is not working over an ant-scenario. the basic function is a simple string-replace-function (xslt1.0) similar to the one Adrian suggested to me. So thats the code which works fine in xslt-scenario, and doesn't work in ant-scenario (here, the hrefs remain all empty):
Code: Select all
<xsl:template match="@href">
<xsl:attribute name="href">
<xsl:choose>
<xsl:when test="contains(. ,'criteria')">
<xsl:attribute name="href">
<xsl:call-template name="string-replace">
<xsl:with-param name="string" select="." />
<xsl:with-param name="replace" select="'fragment1'" />
<xsl:with-param name="with" select="'fragment1_new'" />
</xsl:call-template>
<xsl:call-template name="string-replace">
<xsl:with-param name="string" select="." />
<xsl:with-param name="replace" select="'fragment2'" />
<xsl:with-param name="with" select="'fragment2_new'" />
</xsl:call-template>
</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="not(contains(. ,'criteria'))">
<xsl:attribute name="href">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:attribute>
</xsl:template>
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