[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] xsl:result-document and Saxon serializer problems


Subject: [xsl] xsl:result-document and Saxon serializer problems
From: Kenneth Stephen <marvin.the.cynical.robot@xxxxxxxxx>
Date: Sat, 20 Aug 2005 23:24:26 -0500

Hi,

    I have the following input data :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!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"
	xmlns:img-parms="http://xml.megadodo.umb/svg"
	img-parms:width="" img-parms:height="" img-parms:x="" img-parms:y="">
	<rect img-parms:x="" img-parms:y="" img-parms:width="" img-parms:height=""
		img-parms:rx="" img-parms:ry="" img-parms:style="">
		<img-parms:data />
	</rect>
</svg>

    ....and the following code :

    			<xsl:result-document href="{$svg-filename}"
doctype-public="-//W3C//DTD SVG 1.1//EN"
    				doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
exclude-result-prefixes="img-parms">
	    			<xsl:call-template name="create-svg">
	    				<xsl:with-param name="template-name"
select="concat($config-dir,$chart-name,'Template.xml')" />
	    				<xsl:with-param name="img-width" select="$width" />
	    				<xsl:with-param name="img-height" select="$height" />
	    			</xsl:call-template>
    			</xsl:result-document>

    <xsl:template name="create-svg">
	    <xsl:param name="template-name" />
    	    <xsl:param name="img-width" />
	    <xsl:param name="img-height" />

            <xsl:if test="$template-name = '' or $img-width = '' or
$img-height = ''">
        	<xsl:message terminate="yes">Invalid input parameters</xsl:message>
    	    </xsl:if>
    	    <xsl:apply-templates select="document($template-name)/*"
mode="chart">
		<xsl:with-param name="template-name" select="$template-name"/>
    		<xsl:with-param name="img-width" select="$img-width" />
	    	<xsl:with-param name="img-height" select="$img-height" />
    	    </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="@*[namespace-uri() != 'http://xml.megadodo.umb/svg']
|
    		node()[namespace-uri() != 'http://xml.megadodo.umb/svg']" mode="chart"
>
	    <xsl:param name="template-name" />
    	<xsl:param name="img-width" />
	    <xsl:param name="img-height" />

    	<xsl:copy>
    		<xsl:apply-templates select="@*|node()" mode="chart">
			    <xsl:with-param name="template-name" select="$template-name"/>
    			<xsl:with-param name="img-width" select="$img-width" />
	    		<xsl:with-param name="img-height" select="$img-height" />
	    	</xsl:apply-templates>
    	</xsl:copy>
    </xsl:template>

    <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart">
	    <xsl:param name="template-name" />
    	<xsl:param name="img-width" />
	    <xsl:param name="img-height" />

    	<xsl:attribute name="{local-name()}">
	    	<xsl:choose>
    			<xsl:when test="local-name() = 'height'">
    				<xsl:value-of select="$img-height" />
    			</xsl:when>
    			<xsl:when test="local-name() = 'width'">
    				<xsl:value-of select="$img-width" />
    			</xsl:when>
    			<xsl:when test="local-name() = 'x' and ../local-name() = 'svg'">
    				<xsl:value-of select="'0'" />
    			</xsl:when>
    			<xsl:when test="local-name() = 'y' and ../local-name() = 'svg'">
    				<xsl:value-of select="'0'" />
    			</xsl:when>
    			<xsl:when test="local-name() = 'x' and ../local-name() = 'rect'">
    				<xsl:value-of select="'0'" />
    			</xsl:when>
    			<xsl:when test="local-name() = 'y' and ../local-name() = 'rect'">
    				<xsl:value-of select="'0'" />
    			</xsl:when>
    			<xsl:when test="local-name() = 'style'">
    				<xsl:value-of select="'fill:yellow;stroke:black'" />
    			</xsl:when>
    			<xsl:otherwise />
	    	</xsl:choose>
    	</xsl:attribute>
    </xsl:template>

    <xsl:template match="img-parms:data" mode="chart" />

    <xsl:template match="text()[../local-name() = 'rect']"
mode="chart" priority="2" />

    This produces the following output :

<?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"
xmlns:img-parms="http://xml.megadodo.umb/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="500" height="500"
x="0" y="0" preserveAspectRatio="xMidYMid meet" zoomAndPan="magnify"
version="1.1" contentScriptType="text/ecmascript"
contentStyleType="text/css">
	<rect x="0" y="0" width="500" height="500" rx="" ry=""
style="fill:yellow;stroke:black"/>
</svg>

Questions:

1.  Why is the saxon serializer defining the namespace of xlink on the
svg element?
2.  Where in heavens name are the preserveAspectRation, zoomAndPan,
etc attributes coming from? Saxon appears to be conjuring them out of
thin air.
3.  The XSLT 2.0 draft specifies that....

<quote>
3.5 Standard Attributes

[Definition: There are a number of standard attributes that may appear
on any XSLT element: specifically version, exclude-result-prefixes,
extension-element-prefixes, xpath-default-namespace,
default-collation, and use-when.]</quote>

    ....and saxon appears to be ignoring the exclude-result-prefixes
that I've specified on the result-document element. Is this valid
behaviour?

Thanks,
Kenneth


Current Thread
Keywords