[xslt] performance: xsl:attribute vs. textual attribute



Hi,

Performance of "xsl:attribute" versus textual attributes.

This mail is related to the optimization request in mail [1].

Did someone already look into it? Is this doable in Libxml2? I did a
little performance testing and the "xsl:attribute" version seems to
quite slower.

The test XML is looks like this:
<?xml version="1.0"?>
<foo>
  <bar/>
  ... 50000 "bar" elements...
</foo>

The stylesheets are attached.

---------------------
With "xsl:attribute":
P:\tests\xsltAttribute>xsltproc --noout --timing test-xsl-attr.xsl test.xml
Parsing stylesheet test-xsl-attr.xsl took 15 ms
Parsing document test.xml took 172 ms
Applying stylesheet took 1343 ms
---------------------
Textual "attribue":
P:\tests\xsltAttribute>xsltproc --noout --timing test-attr.xsl test.xml
Parsing stylesheet test-attr.xsl took 0 ms
Parsing document test.xml took 172 ms
Applying stylesheet took 2984 ms
---------------------
Note that only the duration ratio is relevant, since I'm running in
a VMware on a turtle machine.

Regarding the mail-thread [2], it seems that XSLT authors are not always
aware of performance differences here.
As a workaround we are currently changing every stylesheet by
substituting attributes for xsl:attribute before transforming.

Greetings,

Kasimier

[1] http://mail.gnome.org/archives/xslt/2003-February/msg00005.html
[2] http://www.biglist.com/lists/xsl-list/archives/200307/msg00163.html
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="xml" indent="yes" />
	<!--xsl:strip-space elements="" /-->

	<xsl:template match="/foo">
		<foo>
		<xsl:for-each select="bar">
			<element>
				<xsl:attribute name="attribute-1">value</xsl:attribute>
				<xsl:attribute name="attribute-2">value</xsl:attribute>
				<xsl:attribute name="attribute-3">value</xsl:attribute>
			</element>
		</xsl:for-each>
		</foo>
	</xsl:template>

</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2004. Sonic Software Corporation. All rights reserved.
<metaInformation>
<scenarios/><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
</metaInformation>
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="xml" indent="yes" />
	<xsl:strip-space elements=""/>

	<xsl:template match="/foo">
		<foo>
		<xsl:for-each select="bar">
			<element attribute-1="value" attribute-2="value" attribute-3="value"/>
		</xsl:for-each>
		</foo>
	</xsl:template>

</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2004. Sonic Software Corporation. All rights reserved.
<metaInformation>
<scenarios/><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
</metaInformation>
-->


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]