Hairi
Hairi

Reputation: 3725

Attribute extension in XSLT task doesn't work

Here is the problem:

I have an XSLT task that suppose to produce an XML file as output. This is the output I am currently getting:

C:\Users\rmrd001\git\xslt-framework\examples\intermediate\odt-folder\t2\t2.1\content

It produces a file without any extension. So the windows doesn't provide default program to open with. Of course, desired result is same but with extension included. Namely:

C:\Users\rmrd001\git\xslt-framework\examples\intermediate\odt-folder\t2\t2.1\content.xml

And here is the task definition:

<xslt in="@{file}" out="${dita-odt.path.odt-unzipped-base-dir}/${common-path}/${file-base-name}" style="${dita-odt.path.text-odt-xsl}" extension="xml" force="true">
                            <param name="dir-path-styles-xml" expression="${dita-odt.path.odt-unzipped-base-dir}/${common-path}"/>
                            <!--The following parameter is designated for reference nodes that require absolute path. For example draw:image/@href. This is to achieve system portability as well.-->
                            <param name="project-base-dir-absolute-path" expression="${base-dir-unix}"/>
                            <classpath location="${infrastructure-base-dir}/${dita-odt.text-odt-xsl.processor}"/>
                        </xslt>

I know this is not the complete script, but everything works fine except the extension missing for the output document. There is no mapper nested into the XSL task. I can also work around it by adding .xml to the path specified into the out attribute like this out="${dita-odt.path.odt-unzipped-base-dir}/${common-path}/${file-base-name}.xml". Anyway, why it doesn't work?

Upvotes: 0

Views: 131

Answers (2)

Chad Nouis
Chad Nouis

Reputation: 7041

For <xslt>, the extension attribute is ignored if either:

  • the out attribute is set
  • or a <mapper> is nested under <xslt>

To have <xslt> output a file with a certain extension, either:

  • provide the extension to out
  • or add a <mapper> that appends the extension

Upvotes: 0

fafl
fafl

Reputation: 7385

You need to specify the full path. If ${file-base-name} does not contain ".xml" at the end, you have to specify it. It would help to see its definition.

The default output for XSLT is not XML, because XSLT can write any content.

Upvotes: 0

Related Questions