variables in XSLTOperation
Oxygen general issues.
-
- Posts: 5
- Joined: Thu Oct 25, 2012 2:02 pm
variables in XSLTOperation
Hi,
Is it possible to use an XSLT via XSLTOperation (ro.sync.ecss.extensions.commons.operations.XSLTOperation) in an Author action to find a value in one part of the document and then use it in a fragment?
This is template I'm trying to use:
to find the name of an image and use it in an xref. But the @linkend is empty after the action has been run.
Thanks,
Tolliver
Is it possible to use an XSLT via XSLTOperation (ro.sync.ecss.extensions.commons.operations.XSLTOperation) in an Author action to find a value in one part of the document and then use it in a fragment?
This is template I'm trying to use:
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xpath-default-namespace="http://docbook.org/ns/docbook">
<xsl:variable name="keyImage" select="//imagedata[@fileref='aGraphic.png']/ancestor::inlinemediaobject/@xml:id/string()"/>
<xsl:template match="para">
<xref linkend="{$keyImage}" role="key_include" xmlns="http://docbook.org/ns/docbook"/>
</xsl:template>
</xsl:stylesheet>
Thanks,
Tolliver
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: variables in XSLTOperation
Post by alex_jitianu »
Hi Tolliver,
I suspect that the XSLTOperation's sourceLocation parameter is empty. As a result, the input for the stylesheet will be the element at caret position and you will not be able to access any other nodes from the original document.
So the first step is to set parameter sourceLocation to be the root element: /*. But now your template will match on every para from the document so it will have to be changed into something like:
If you need to pass as a sourceLocation an ancestor of the caret element and still be able to write a template that matches that caret element, you can do it like this:
oXygen will automatically bind parameter currentElementLocation to the XPath location of the caret element relative to the source element (provided that the source element is an ancestor of the caret element).
Best regards,
Alex
I suspect that the XSLTOperation's sourceLocation parameter is empty. As a result, the input for the stylesheet will be the element at caret position and you will not be able to access any other nodes from the original document.
So the first step is to set parameter sourceLocation to be the root element: /*. But now your template will match on every para from the document so it will have to be changed into something like:
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xpath-default-namespace="http://docbook.org/ns/docbook">
<xsl:template match="imagedata[@fileref='images/lake.jpeg']">
<xref linkend="{ancestor::inlinemediaobject/@xml:id/string()}" role="key_include" xmlns="http://docbook.org/ns/docbook"/>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xpath-default-namespace="http://docbook.org/ns/docbook" xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="saxon">
<xsl:param name="currentElementLocation"/>
<xsl:template match="/">
<xsl:apply-templates select="saxon:eval(saxon:expression($currentElementLocation))"/>
</xsl:template>
<xsl:template match="para">
<xsl:variable name="keyImage" select="//imagedata[@fileref='images/lake.jpeg']/ancestor::inlinemediaobject/@xml:id/string()"/>
<xref linkend="{$keyImage}" role="key_include" xmlns="http://docbook.org/ns/docbook"/>
</xsl:template>
</xsl:stylesheet>
Best regards,
Alex
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: variables in XSLTOperation
Post by alex_jitianu »
Hi Tolliver,
You may also find it interesting to save your script file in the directory of your framework and use as *script* the following driver:
The import is resolved relative to the framework directory. This way is much easier to make changes in your script and test them by immediately running the operation.
Best regards,
Alex
You may also find it interesting to save your script file in the directory of your framework and use as *script* the following driver:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:import href="xslt_operation.xsl"/>
</xsl:stylesheet>
Best regards,
Alex
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