exslt support for Model View and documenting XSLT?

Here should go questions about transforming XML with XSLT and FOP.
KampfCaspar
Posts: 8
Joined: Sun Mar 21, 2010 2:26 pm

exslt support for Model View and documenting XSLT?

Post by KampfCaspar »

Hi!

Fortunately, exslt support is quite widespread and can be used in oxygen also...

However, I find Oxygen itself is lacking "support":
a) No useful information in the "Model View"
b) exslt elements are ignored in xslt documentation (esp. user-defined functions)

Is there any way to add at least partial support?

I presume the "Model View" is read from a schema file. Adding exslt schemas (even by the user) should not be that difficult, shouldn't it?

If I overlooked something, please excuse my ignorance...

HP
adrian
Posts: 2850
Joined: Tue May 17, 2005 4:01 pm

Re: exslt support for Model View and documenting XSLT?

Post by adrian »

Hello,

The EXSLT support in Oxygen consists solely in processing(which is actually provided by the XSLT engines rather than Oxygen itself). There are no EXSLT helpers: content completion or documentation.

On our issue tracking tool we already have a feature request for these helpers so eventually they will be implemented.

If you want to add an additional schema that contributes to the content completion of elements when editing an XSL file, you can do so in Options -> Preferences -> Editor -> Content Completion -> XSL, Include Elements declared in the schema, Custom Schema.
Though I'm not sure how useful this would be for EXSLT since most of its additions consist in functions(rather than elements) for which the content completion cannot be extended this way.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
ra0543
Posts: 80
Joined: Wed Jan 14, 2009 12:50 pm

Documenting XSLT?

Post by ra0543 »

If you want to add an additional schema that contributes to the content completion of elements when editing an XSL file, you can do so in Options -> Preferences -> Editor -> Content Completion -> XSL, Include Elements declared in the schema, Custom Schema.
I tried this, referring to a schema which describes an element 'documentation' which then includes all the other description elements I want to include. These show up fine in content completion, but my XSL is then not valid and the transformation will not work!

e.g.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<documentation xml:id="a12">
<input>
<filetype></filetype>
<fileschema></fileschema>
</input>
<output>
<filetype></filetype>
<fileschema></fileschema>
</output>
<description></description>
</documentation>

<xsl:output method="html"/>
<xsl:template match="/">
<html> ...
I get the following errors:
Description: Failed to compile stylesheet. 2 errors detected.

Severity: fatal
Description: Element documentation must not appear directly within xsl:stylesheet because it is not in a namespace

Severity: fatal
Description: Top level elements must have a non-null namespace URI
How can I correct this and still have only valid elements (including these) available in content completion?
adrian
Posts: 2850
Joined: Tue May 17, 2005 4:01 pm

Re: exslt support for Model View and documenting XSLT?

Post by adrian »

Hi,

Note that Oxygen has a built-in documentation schema that is used by default. Create a new XSL file(File -> New -> XSL) and you will see the type of documentation offered by the built-in documentation schema.

If you want to change the documentation schema then you should set the custom schema in the "Documentation schema" subsection from the same option page(Options -> Preferences -> Editor -> Content Completion -> XSL).

And set the schema from "Include Elements declared in the schema" back to its "XHTML transitional" default if you are going to use XHTML elements in the stylesheet.

Also,
Element documentation must not appear directly within xsl:stylesheet because it is not in a namespace
The error message kind of gives it away. You have to declare a namespace for the documentation elements.
You can see this used in any new stylesheet created from Oxygen.

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
exclude-result-prefixes="xd"
version="1.0">
<xd:doc scope="stylesheet">
<xd:desc>
<xd:p><xd:b>Created on:</xd:b> Oct 26, 2010</xd:p>
<xd:p><xd:b>Author:</xd:b> adrian</xd:p>
<xd:p></xd:p>
</xd:desc>
</xd:doc>

</xsl:stylesheet>
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" is used for the built-in documentation.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
ra0543
Posts: 80
Joined: Wed Jan 14, 2009 12:50 pm

Documenting XSLT?

Post by ra0543 »

Thanks. I sort of figured that out but was struggling to make the second namespace work.

Can I then ensure that when I validate my XSL files, the <xd:*> parts are validated against the relevant schema for them? At the moment, it seems that when I validate the XSL file, any elements in the xd namespace are completely ignored and so even if they are not validly structured the file as whole is reported as valid.
adrian
Posts: 2850
Joined: Tue May 17, 2005 4:01 pm

Re: exslt support for Model View and documenting XSLT?

Post by adrian »

No, I'm afraid there's no validation against any of these additional schemas. The schemas are only used for content completion.

I have to investigate a little if there's some way to do this with a custom validation scenario.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
adrian
Posts: 2850
Joined: Tue May 17, 2005 4:01 pm

Re: exslt support for Model View and documenting XSLT?

Post by adrian »

Hi,

You can validate the documentation sections from the stylesheet against their schema with the help of a NVDL schema.

Create a new NVDL schema with this content:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" startMode="xslt">
<mode name="xslt">
<namespace ns="http://www.w3.org/1999/XSL/Transform">
<allow useMode="allowAll">
<context path="stylesheet" useMode="doc"/>
</allow>
</namespace>
<anyNamespace>
<reject/>
</anyNamespace>
</mode>

<mode name="doc">
<anyNamespace>
<validate schema="stylesheet_documentation.xsd" useMode="attachDoc"/>
</anyNamespace>
</mode>

<mode name="allowAll">
<anyNamespace>
<allow/>
</anyNamespace>
</mode>
<mode name="attachDoc">
<anyNamespace>
<attach/>
</anyNamespace>
</mode>
</rules>
Change the schema(stylesheet_documentation.xsd) to your own documentation schema.

To validate both the XSLT and its documentation you need to create a custom validation scenario for the stylesheet file(Document -> Validate -> "Configure Validation Scenario", "Use custom validation scenario", New) then add two validation units:

1. A validation unit of XSLT Document type. This is the default so in the "New scenario" dialog you simply have to press "Add" and OK.

2. A validation unit of XML Document type that uses the default engine and the NVDL schema above.

Now when the stylesheet is validated(either manually or automatically) both the stylesheet content and the documentation content will be validated.

For all additional stylesheets that you want to validate this way you will have to associate this validation scenario.
You can do this easily with multiple files in the Project view. Select the XSL files(or their parent folder) in the project view and right click and select Validate -> Configure Validation Scenario. Then choose "Use custom validation scenario", select the scenario from the list and press OK.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
ra0543
Posts: 80
Joined: Wed Jan 14, 2009 12:50 pm

Documenting XSLT?

Post by ra0543 »

Thanks. I'll try that when I get a moment.
Post Reply