Problem with custom action in Author Mode

Post here questions and problems related to oXygen frameworks/document types.
martindholmes
Posts: 191
Joined: Wed Apr 20, 2005 5:43 pm
Location: Victoria, BC, Canada

Problem with custom action in Author Mode

Post by martindholmes »

HI there,

I have a project (xpr) file in which I'm defining some custom actions for Author Mode editing. In one of them, I'm trying to use the ro.sync.ecss.extensions.commons.operations.XSLTOperation operation to run some XSLT on a selected element. The XSLT script location is specified as:

${pd}/oxygen/xsl/toggle_italic.xsl

All the other variables are set to their defaults.

When I try to run the action from the menu with an element selected, I get this error:

Couldn't execute operation: 'ro.sync.ecss.extensions.commons.operations.XSLTOperation' for action: 'Test' because of: Cannot create a transformer from the provided script:
${pd}/oxygen/xsl/toggle_italic.xsl
Reason:E org.xml.sax.SAXParseException; systemId: file:/home/mholmes/WorkData/english/scancan2/svnrepo/scanning/vol01/hocr_orig/2015_12_07_10_38_33_002.hocr; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
F Content is not allowed in prolog. at line 1 and column 1

Both the XSLT and the source file are valid.

This is the complete XSLT:

Code: Select all


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" 
xpath-default-namespace="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="saxon">

<xsl:template match="/">
<xsl:choose>
<xsl:when test="descendant::em">
<xsl:apply-templates mode="removeEm"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates mode="addEm"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="em" mode="removeEm">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="text()" mode="addEm">
<em><xsl:copy-of select="."/></em>
</xsl:template>

<!-- Copy everything else as-is. -->
<xsl:template match="@*|node()" priority="-1" mode="#all">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Can anyone see what I've screwed up here?

All help appreciated,
Martin
Radu
Posts: 9470
Joined: Fri Jul 09, 2004 5:18 pm

Re: Problem with custom action in Author Mode

Post by Radu »

Hi Martin,

This type of problem could occur if Oxygen cannot find the XSLT script in that precise location after it has expanded the editor variables.
So could you double check the XSLT is located in?

${pd}/oxygen/xsl/toggle_italic.xsl

The ${pd} editor variable expands to the folder where the project "projectName.xpr" configuration file is located.

The script parameter for the XSLTOperation can either be a small XSLT or a path to one so if Oxygen cannot located the value of the script parameter as a file on disk, it will consider that it is actually XSLT content so it will try to parse that value as XSLT, leading to that ambiguous error you received and which we'll try to improve.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
martindholmes
Posts: 191
Joined: Wed Apr 20, 2005 5:43 pm
Location: Victoria, BC, Canada

Re: Problem with custom action in Author Mode

Post by martindholmes »

The XSLT is definitely in the right location. so I'm still puzzled, but at least I understand the error message now. :-)

Cheers,
Martin
Radu
Posts: 9470
Joined: Fri Jul 09, 2004 5:18 pm

Re: Problem with custom action in Author Mode

Post by Radu »

Hi Martin,

One more thing, could you try to use ${pdu} instead of ${pd}?

Something like:
${pdu}/oxygen/xsl/toggle_italic.xsl

I'm testing on a very new development Oxygen version 18 and both specifying the path as an URL or as a file location works but it might be possible that in Oxygen 17.1 you needed to specify the path only as an URL and not as a file path.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
whyme
Posts: 94
Joined: Fri Mar 08, 2013 8:58 am

Re: Problem with custom action in Author Mode

Post by whyme »

I'm running into the same problem as Martin, but have decided to use this hack/workaround in lieu of a script, until the problem can be addressed:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:include href="oxygen/xsl/toggle_italic.xsl"/>
</xsl:stylesheet>
alex_jitianu
Posts: 1017
Joined: Wed Nov 16, 2005 11:11 am

Re: Problem with custom action in Author Mode

Post by alex_jitianu »

Hi,

To try and clarify things a bit.... In version 17.1 the only way to use an external XSLT is through a driver script:

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:include href="oxygen/xsl/toggle_italic.xsl"/>
</xsl:stylesheet>
The include is resolved relative to the framework location.

In the next version (18.0) you will also be able to give directly a relative path or a path containing editor variables (like Martin tried). That path will also be passed through catalog mappings to give you more flexibility on how you map the paths to real resources.

Best regards,
Alex
Post Reply