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

Subject: Re: [xsl] xsl:result-document and Saxon serializer problems
From: Kenneth Stephen <marvin.the.cynical.robot@xxxxxxxxx>
Date: Sun, 21 Aug 2005 08:21:45 -0500
Michael,

    I'm posting the complete code, below as well as the output
produced via -T. I do have a question about your answer, below,
though. In XSLT 1.0, whenever I applied exlcude-result-prefixes to the
xsl-stylesheet element, it worked on the entire result tree - not just
LRE's. Atleast thats the way I remember it - I may be able to work out
a testcase later. Did the behaviour of this attribute change in XSLT
2.0? It seems to me that this behaviour is much more useful over the
entire result document rather than LRE's only. Why is this defined the
way it is in 2.0?

    Also, I didnt understand your point (b). I did want it to apply
only to everything within that result-document element.

Input data svg/config/ChartTemplate.xml:

<?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>

Code file svg/code/PageTemplate.xsl :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
	xmlns:img-parms="http://xml.megadodo.umb/svg";
    version="2.0">

    <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
    	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
method="xml" />

    <xsl:param name="width" select="'500'" />
    <xsl:param name="height" select="'500'" />

    <xsl:variable name="chart-name" select="'Chart'" />
    <xsl:variable name="chart-location" select="'svg/data/'" />
    <xsl:variable name="config-dir" select="'../config/'" />

    <xsl:include href="SVGRoutines.xsl" />

    <xsl:template match="/">
    	<html>
    		<head><title>A title</title></head>
    		<body>
    			<xsl:variable name="svg-filename"
select="concat($chart-location,$chart-name,'.svg')" />
    			<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>
    			<object data="{$svg-filename}" width="{$width}"
height="{$height}" type="image/svg+xml" />
    		</body>
    	</html>
    </xsl:template>

</xsl:stylesheet>

Code file svg/code/SVGRoutines.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
	xmlns:img-parms="http://xml.megadodo.umb/svg";
	xmlns:svg="http://www.w3.org/2000/svg";
    version="2.0">

    <!-- xsl:output doctype-public="-//W3C//DTD SVG 1.1//EN"
    	doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"; /-->

    <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" />

</xsl:stylesheet>

Invocation : java net.sf.saxon.Transform -T svg/code/PageTemplate.xsl
svg/code/PageTemplate.xsl

Output produced (stdout + stderr) :

<trace saxon-version="8.5" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:variable name="config-dir" select="'../config/'" line="14"
module="PageTemplate.xsl">
 </xsl:variable>
 <xsl:variable name="chart-location" select="'svg/data/'" line="13"
module="PageTemplate.xsl">
 </xsl:variable>
 <xsl:variable name="height" select="'500'" line="10"
module="PageTemplate.xsl">
 </xsl:variable>
 <xsl:variable name="chart-name" select="'Chart'" line="12"
module="PageTemplate.xsl">
 </xsl:variable>
 <xsl:variable name="width" select="'500'" line="9"
module="PageTemplate.xsl">
 </xsl:variable>
 <source node="/" line="0" file="PageTemplate.xsl">
  <xsl:template match="/" line="18" module="PageTemplate.xsl">
   <LRE name="html" line="19" module="PageTemplate.xsl">
    <LRE name="head" line="20" module="PageTemplate.xsl">
     <LRE name="title" line="20" module="PageTemplate.xsl">
     </LRE>
    </LRE>
    <LRE name="body" line="21" module="PageTemplate.xsl">
     <xsl:variable name="svg-filename" line="22" module="PageTemplate.xsl">
      <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" line="24"
module="PageTemplate.xsl">
       <xsl:call-template name="create-svg" line="25"
module="PageTemplate.xsl">
        <xsl:template name="create-svg" line="10" module="SVGRoutines.xsl">
         <xsl:variable name="template-name" line="11"
module="SVGRoutines.xsl">
         </xsl:variable>
         <xsl:variable name="img-width" line="12" module="SVGRoutines.xsl">
         </xsl:variable>
         <xsl:variable name="img-height" line="13" module="SVGRoutines.xsl">
         </xsl:variable>
         <xsl:if test="$template-name = '' or $img-width = '' or
$img-height = ''" line="15" module="SVGRoutines.xsl">
         </xsl:if>
         <xsl:apply-templates select="document($template-name)/*"
mode="chart" line="18" module="SVGRoutines.xsl">
          <source node="/svg" line="6" file="ChartTemplate.xml">
           <xsl:template match="@*[namespace-uri() !=
'http://xml.megadodo.umb/svg'] | node()[namespace-uri() !=
'http://xml.megadodo.umb/svg']" mode="chart" line="26"
module="SVGRoutines.xsl">
            <xsl:variable name="template-name" line="27"
module="SVGRoutines.xsl">
            </xsl:variable>
            <xsl:variable name="img-width" line="28"
module="SVGRoutines.xsl">
            </xsl:variable>
            <xsl:variable name="img-height" line="29"
module="SVGRoutines.xsl">
            </xsl:variable>
            <xsl:copy line="31" module="SVGRoutines.xsl">
             <xsl:apply-templates select="@*|node()" mode="chart"
line="32" module="SVGRoutines.xsl">
              <source node="/svg/@img-parms:width" line="6"
file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                 <xsl:choose line="46" module="SVGRoutines.xsl">
                  <xsl:value-of select="$img-width" line="51"
module="SVGRoutines.xsl">
                  </xsl:value-of>
                 </xsl:choose>
                </xsl:attribute>
               </xsl:template>
              </source><!-- /svg/@img-parms:width -->
              <source node="/svg/@img-parms:height" line="6"
file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                 <xsl:choose line="46" module="SVGRoutines.xsl">
                  <xsl:value-of select="$img-height" line="48"
module="SVGRoutines.xsl">
                  </xsl:value-of>
                 </xsl:choose>
                </xsl:attribute>
               </xsl:template>
              </source><!-- /svg/@img-parms:height -->
              <source node="/svg/@img-parms:x" line="6"
file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                 <xsl:choose line="46" module="SVGRoutines.xsl">
                  <xsl:value-of select="'0'" line="54"
module="SVGRoutines.xsl">
                  </xsl:value-of>
                 </xsl:choose>
                </xsl:attribute>
               </xsl:template>
              </source><!-- /svg/@img-parms:x -->
              <source node="/svg/@img-parms:y" line="6"
file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                 <xsl:choose line="46" module="SVGRoutines.xsl">
                  <xsl:value-of select="'0'" line="57"
module="SVGRoutines.xsl">
                  </xsl:value-of>
                 </xsl:choose>
                </xsl:attribute>
               </xsl:template>
              </source><!-- /svg/@img-parms:y -->
              <source node="/svg/@preserveAspectRatio" line="6"
file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() !=
'http://xml.megadodo.umb/svg'] | node()[namespace-uri() !=
'http://xml.megadodo.umb/svg']" mode="chart" line="26"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="27"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="28"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="29"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:copy line="31" module="SVGRoutines.xsl">
                </xsl:copy>
               </xsl:template>
              </source><!-- /svg/@preserveAspectRatio -->
              <source node="/svg/@zoomAndPan" line="6"
file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() !=
'http://xml.megadodo.umb/svg'] | node()[namespace-uri() !=
'http://xml.megadodo.umb/svg']" mode="chart" line="26"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="27"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="28"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="29"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:copy line="31" module="SVGRoutines.xsl">
                </xsl:copy>
               </xsl:template>
              </source><!-- /svg/@zoomAndPan -->
              <source node="/svg/@version" line="6" file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() !=
'http://xml.megadodo.umb/svg'] | node()[namespace-uri() !=
'http://xml.megadodo.umb/svg']" mode="chart" line="26"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="27"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="28"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="29"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:copy line="31" module="SVGRoutines.xsl">
                </xsl:copy>
               </xsl:template>
              </source><!-- /svg/@version -->
              <source node="/svg/@contentScriptType" line="6"
file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() !=
'http://xml.megadodo.umb/svg'] | node()[namespace-uri() !=
'http://xml.megadodo.umb/svg']" mode="chart" line="26"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="27"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="28"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="29"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:copy line="31" module="SVGRoutines.xsl">
                </xsl:copy>
               </xsl:template>
              </source><!-- /svg/@contentScriptType -->
              <source node="/svg/@contentStyleType" line="6"
file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() !=
'http://xml.megadodo.umb/svg'] | node()[namespace-uri() !=
'http://xml.megadodo.umb/svg']" mode="chart" line="26"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="27"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="28"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="29"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:copy line="31" module="SVGRoutines.xsl">
                </xsl:copy>
               </xsl:template>
              </source><!-- /svg/@contentStyleType -->
              <source node="/svg/text()[1]" line="6"
file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() !=
'http://xml.megadodo.umb/svg'] | node()[namespace-uri() !=
'http://xml.megadodo.umb/svg']" mode="chart" line="26"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="27"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="28"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="29"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:copy line="31" module="SVGRoutines.xsl">
                </xsl:copy>
               </xsl:template>
              </source><!-- /svg/text()[1] -->
              <source node="/svg/rect[1]" line="8" file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() !=
'http://xml.megadodo.umb/svg'] | node()[namespace-uri() !=
'http://xml.megadodo.umb/svg']" mode="chart" line="26"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="27"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="28"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="29"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:copy line="31" module="SVGRoutines.xsl">
                 <xsl:apply-templates select="@*|node()" mode="chart"
line="32" module="SVGRoutines.xsl">
                  <source node="/svg/rect[1]/@img-parms:x" line="8"
file="ChartTemplate.xml">
                   <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                    <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                     <xsl:choose line="46" module="SVGRoutines.xsl">
                      <xsl:value-of select="'0'" line="60"
module="SVGRoutines.xsl">
                      </xsl:value-of>
                     </xsl:choose>
                    </xsl:attribute>
                   </xsl:template>
                  </source><!-- /svg/rect[1]/@img-parms:x -->
                  <source node="/svg/rect[1]/@img-parms:y" line="8"
file="ChartTemplate.xml">
                   <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                    <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                     <xsl:choose line="46" module="SVGRoutines.xsl">
                      <xsl:value-of select="'0'" line="63"
module="SVGRoutines.xsl">
                      </xsl:value-of>
                     </xsl:choose>
                    </xsl:attribute>
                   </xsl:template>
                  </source><!-- /svg/rect[1]/@img-parms:y -->
                  <source node="/svg/rect[1]/@img-parms:width"
line="8" file="ChartTemplate.xml">
                   <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                    <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                     <xsl:choose line="46" module="SVGRoutines.xsl">
                      <xsl:value-of select="$img-width" line="51"
module="SVGRoutines.xsl">
                      </xsl:value-of>
                     </xsl:choose>
                    </xsl:attribute>
                   </xsl:template>
                  </source><!-- /svg/rect[1]/@img-parms:width -->
                  <source node="/svg/rect[1]/@img-parms:height"
line="8" file="ChartTemplate.xml">
                   <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                    <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                     <xsl:choose line="46" module="SVGRoutines.xsl">
                      <xsl:value-of select="$img-height" line="48"
module="SVGRoutines.xsl">
                      </xsl:value-of>
                     </xsl:choose>
                    </xsl:attribute>
                   </xsl:template>
                  </source><!-- /svg/rect[1]/@img-parms:height -->
                  <source node="/svg/rect[1]/@img-parms:rx" line="8"
file="ChartTemplate.xml">
                   <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                    <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                     <xsl:choose line="46" module="SVGRoutines.xsl">
                      <xsl:otherwise line="68" module="SVGRoutines.xsl">
                      </xsl:otherwise>
                     </xsl:choose>
                    </xsl:attribute>
                   </xsl:template>
                  </source><!-- /svg/rect[1]/@img-parms:rx -->
                  <source node="/svg/rect[1]/@img-parms:ry" line="8"
file="ChartTemplate.xml">
                   <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                    <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                     <xsl:choose line="46" module="SVGRoutines.xsl">
                      <xsl:otherwise line="68" module="SVGRoutines.xsl">
                      </xsl:otherwise>
                     </xsl:choose>
                    </xsl:attribute>
                   </xsl:template>
                  </source><!-- /svg/rect[1]/@img-parms:ry -->
                  <source node="/svg/rect[1]/@img-parms:style"
line="8" file="ChartTemplate.xml">
                   <xsl:template match="@*[namespace-uri() =
'http://xml.megadodo.umb/svg']" mode="chart" line="40"
module="SVGRoutines.xsl">
                    <xsl:variable name="template-name" line="41"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-width" line="42"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:variable name="img-height" line="43"
module="SVGRoutines.xsl">
                    </xsl:variable>
                    <xsl:attribute name="{local-name()}" line="45"
module="SVGRoutines.xsl">
                     <xsl:choose line="46" module="SVGRoutines.xsl">
                      <xsl:value-of
select="'fill:yellow;stroke:black'" line="66"
module="SVGRoutines.xsl">
                      </xsl:value-of>
                     </xsl:choose>
                    </xsl:attribute>
                   </xsl:template>
                  </source><!-- /svg/rect[1]/@img-parms:style -->
                  <source node="/svg/rect[1]/text()[1]" line="8"
file="ChartTemplate.xml">
                   <xsl:template match="text()[../local-name() =
'rect']" mode="chart" priority="2" line="75" module="SVGRoutines.xsl">
                   </xsl:template>
                  </source><!-- /svg/rect[1]/text()[1] -->
                  <source node="/svg/rect[1]/img-parms:data[1]"
line="9" file="ChartTemplate.xml">
                   <xsl:template match="img-parms:data" mode="chart"
line="73" module="SVGRoutines.xsl">
                   </xsl:template>
                  </source><!-- /svg/rect[1]/img-parms:data[1] -->
                  <source node="/svg/rect[1]/text()[2]" line="9"
file="ChartTemplate.xml">
                   <xsl:template match="text()[../local-name() =
'rect']" mode="chart" priority="2" line="75" module="SVGRoutines.xsl">
                   </xsl:template>
                  </source><!-- /svg/rect[1]/text()[2] -->
                 </xsl:apply-templates>
                </xsl:copy>
               </xsl:template>
              </source><!-- /svg/rect[1] -->
              <source node="/svg/text()[2]" line="9"
file="ChartTemplate.xml">
               <xsl:template match="@*[namespace-uri() !=
'http://xml.megadodo.umb/svg'] | node()[namespace-uri() !=
'http://xml.megadodo.umb/svg']" mode="chart" line="26"
module="SVGRoutines.xsl">
                <xsl:variable name="template-name" line="27"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-width" line="28"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:variable name="img-height" line="29"
module="SVGRoutines.xsl">
                </xsl:variable>
                <xsl:copy line="31" module="SVGRoutines.xsl">
                </xsl:copy>
               </xsl:template>
              </source><!-- /svg/text()[2] -->
             </xsl:apply-templates>
            </xsl:copy>
           </xsl:template>
          </source><!-- /svg -->
         </xsl:apply-templates>
        </xsl:template>
       </xsl:call-template>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns:img-parms="http://xml.megadodo.umb/svg";><head><title>A
title</title></head><body><object data="svg/data/Chart.svg"
width="500" height="500" type="image/svg+xml"/></body></html>
</xsl:result-document>
      <LRE name="object" line="31" module="PageTemplate.xsl">
      </LRE>
     </xsl:variable>
    </LRE>
   </LRE>
  </xsl:template>
 </source><!-- / -->
</trace>

On 8/21/05, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> I suspect the answer to questions 1 and 2 lies in the bits of the
stylesheet
> that you haven't shown us.
>
> The answer to question 3 is that you seem to have misunderstood
> exclude-result-prefixes:
>
> (a) it only affects the behavior of literal result elements, and I don't
see
> any literal result elements in your code
>
> (b) its scope is static rather than dynamic. If you put the attribute on an
> element such as xsl:result-document, it only affects literal result
elements
> that are physically contained within that xsl:result-document element.
>
> To work out where the "thin air" attributes are coming from, I can assure
> you Saxon isn't making them up! You might find that the -T trace option
> helps with your debugging.
>
> Michael Kay
> http://www.saxonica.com/
>
>

resulting svd/data/Chart.svg:

<?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>

Thanks,
Kenneth
 >
> > 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