Saxon: namespace-alias removes the required xmlns attribute
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 3
- Joined: Fri Oct 17, 2008 11:49 am
Saxon: namespace-alias removes the required xmlns attribute
I have the problem to create SVG output with XSLT Saxon8 that should look like following snippet, but I cannot get the xmlns attribute into the output!
With the following INCLUDED in the XSLT the attribute xmlns="http://www.w3.org/2000/svg" is removed from the result at any spot and cannot be included (not using exclude-result-prefixes for svg).
With exactly this line REMOVED in the XSLT the result looks like that and gives errors in Xerces (Element type "svg:svg" must be declared):
Any hints are appreciated!
Thanks for any help & hints!
I am using Oxygen 8.2, but upgraded the saxon jars to the latest.
----
Code: Select all
<!DOCTYPE svg
PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="1280" xmlns="http://www.w3.org/2000/svg" version="1.1">
Code: Select all
<xsl:namespace-alias stylesheet-prefix="svg" result-prefix="#default"/>
Code: Select all
<!DOCTYPE svg:svg
PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg:svg xmlns:svg="http://www.w3.org/2000/svg" width="100%" height="1280" version="1.1">
<svg:g transform="translate(0,0)">
Thanks for any help & hints!
I am using Oxygen 8.2, but upgraded the saxon jars to the latest.
----
Code: Select all
<xsl:stylesheet version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:svg="http://www.w3.org/2000/svg"
exclude-result-prefixes="fn xs">
<xsl:output
method="xml"
doctype-public="-//W3C//DTD SVG 1.0//EN"
doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
media-type="image/svg+xml"
version="1.0"
xmlns="http://www.w3.org/2000/svg"
indent="yes"/>
<!--<xsl:namespace-alias stylesheet-prefix="svg" result-prefix="#default"/>-->
<xsl:template match="/">
<svg:svg width="100%" height="100%" version="1.1">
<xsl:apply-templates select="...."/>
</svg:svg>
</xsl:template>
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Saxon: namespace-alias removes the required xmlns attribute
Post by sorin_ristache »
Hello,
I think Saxon should add the declaration of the default namespace xmlns:svg="http://www.w3.org/2000/svg" in the result of the transformation:
The specification says that "In the event that the same URI is used as a literal namespace URI and a target namespace URI, the second of these rules takes precedence." It seems it is a Saxon bug. To avoid it you should set the default namespace to the SVG namespace in the stylesheet:
Regards,
Sorin
When you usekatzlbt wrote:I have the problem to create SVG output with XSLT Saxon8 that should look like following snippet, but I cannot get the xmlns attribute into the output!
Code: Select all
<!DOCTYPE svg
PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="1280" xmlns="http://www.w3.org/2000/svg" version="1.1">
Code: Select all
<xsl:namespace-alias stylesheet-prefix="svg" result-prefix="#default"/>
Code: Select all
<svg xmlns="http://www.w3.org/2000/svg" ...
Code: Select all
<xsl:stylesheet version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/2000/svg"
exclude-result-prefixes="fn xs">
...
<xsl:template match="/">
<svg width="100%" height="100%" version="1.1">
<g transform="translate(0,0)"/>
</svg>
</xsl:template>
</xsl:stylesheet>
Sorin
-
- Posts: 3
- Joined: Fri Oct 17, 2008 11:49 am
Re: Saxon: namespace-alias removes the required xmlns attribute
Thanks alot!
This really produced the desired result.
I thought I had tried that too, but apparently I haven't.

This really produced the desired result.
I thought I had tried that too, but apparently I haven't.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/2000/svg"
exclude-result-prefixes="fn xs">
<xsl:output
method="xml"
doctype-public="-//W3C//DTD SVG 1.1//EN"
doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
media-type="image/svg+xml"
xmlns="http://www.w3.org/2000/svg"
indent="yes"/>
... no alias ...
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg
PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="300" version="1.1">
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