S
skippyd277
I'm attempting to create an OOXML spreadsheet rom an existing XML
document. I have only one problem at this point and I can't seem to
find a solution. The OOXML spec requires a file named
[Content_Types].xml within the structure of the OOXML file. I can NOT
get saxon to output any file name containing a square bracket.
Everytime I try I get an error
Error at xsl:result-document on line ## of file:/path/to/file/
transform.xslt:
Exception thrown by OutputURIResolver: Invalid syntax for base URI:
Illegal character in
path at index ##: escape-uri(./ooxmlFileName/[Content_Types].xml)
Transformation failed: Run-time errors were reported
The relevant portions of my stylesheet is:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:xls="http://schemas.openxmlformats.org/spreadsheetml/
2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/
2006/relationships">
<xslutput method="xml" indent="yes" encoding="UTF-8"
standalone="yes"/>
<xsl:template match="/">
<xsl:variable name="contentTypesFileName">./<xsl:value-of select="/
path/to/ooxmlFileName"/>/[Content_Types].xml</xsl:variable>
<!-- [ContentTypes].xml -->
<xsl:result-document href="escape-uri({$contentTypesFileName})">
<xsl:element name="Types" namespace="http://
schemas.openxmlformats.org/package/2006/content-types">
<xsl:element name="Default" namespace="http://
schemas.openxmlformats.org/package/2006/content-types">
<xsl:attribute name="Extension">rels</xsl:attribute>
<xsl:attribute name="ContentType">application/
vnd.openxmlformats-package.relationships+xml</xsl:attribute>
</xsl:element>
<xsl:element name="Default" namespace="http://
schemas.openxmlformats.org/package/2006/content-types">
<xsl:attribute name="Extension">xml</xsl:attribute>
<xsl:attribute name="ContentType">application/xml</
xsl:attribute>
</xsl:element>
<xsl:element name="Override" namespace="http://
schemas.openxmlformats.org/package/2006/content-types">
<xsl:attribute name="PartName">/workbook.xml</xsl:attribute>
<xsl:attribute name="ContentType">application/
vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml</
xsl:attribute>
</xsl:element>
<xsl:element name="Override" namespace="http://
schemas.openxmlformats.org/package/2006/content-types">
<xsl:attribute name="PartName">/sheet1.xml</xsl:attribute>
<xsl:attribute name="ContentType">application/
vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml</
xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>
I'm using Saxon 9.0.0.2J with Java 1.6.0_05 on a fully updated Windows
XP machine.
Suggestions will be greatly appreciated
Thanks,
Skippy
document. I have only one problem at this point and I can't seem to
find a solution. The OOXML spec requires a file named
[Content_Types].xml within the structure of the OOXML file. I can NOT
get saxon to output any file name containing a square bracket.
Everytime I try I get an error
Error at xsl:result-document on line ## of file:/path/to/file/
transform.xslt:
Exception thrown by OutputURIResolver: Invalid syntax for base URI:
Illegal character in
path at index ##: escape-uri(./ooxmlFileName/[Content_Types].xml)
Transformation failed: Run-time errors were reported
The relevant portions of my stylesheet is:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:xls="http://schemas.openxmlformats.org/spreadsheetml/
2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/
2006/relationships">
<xslutput method="xml" indent="yes" encoding="UTF-8"
standalone="yes"/>
<xsl:template match="/">
<xsl:variable name="contentTypesFileName">./<xsl:value-of select="/
path/to/ooxmlFileName"/>/[Content_Types].xml</xsl:variable>
<!-- [ContentTypes].xml -->
<xsl:result-document href="escape-uri({$contentTypesFileName})">
<xsl:element name="Types" namespace="http://
schemas.openxmlformats.org/package/2006/content-types">
<xsl:element name="Default" namespace="http://
schemas.openxmlformats.org/package/2006/content-types">
<xsl:attribute name="Extension">rels</xsl:attribute>
<xsl:attribute name="ContentType">application/
vnd.openxmlformats-package.relationships+xml</xsl:attribute>
</xsl:element>
<xsl:element name="Default" namespace="http://
schemas.openxmlformats.org/package/2006/content-types">
<xsl:attribute name="Extension">xml</xsl:attribute>
<xsl:attribute name="ContentType">application/xml</
xsl:attribute>
</xsl:element>
<xsl:element name="Override" namespace="http://
schemas.openxmlformats.org/package/2006/content-types">
<xsl:attribute name="PartName">/workbook.xml</xsl:attribute>
<xsl:attribute name="ContentType">application/
vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml</
xsl:attribute>
</xsl:element>
<xsl:element name="Override" namespace="http://
schemas.openxmlformats.org/package/2006/content-types">
<xsl:attribute name="PartName">/sheet1.xml</xsl:attribute>
<xsl:attribute name="ContentType">application/
vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml</
xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>
I'm using Saxon 9.0.0.2J with Java 1.6.0_05 on a fully updated Windows
XP machine.
Suggestions will be greatly appreciated
Thanks,
Skippy