import_1-input.xml
<?xml version="1.0"?>
<products>
<product
id="p1" name="Delta" price="3250" stock="4"/>
<product
id="p2" name="Golf" price="1000" stock="5"/>
<product
id="p3" name="Alpha" price="1200" stock="19"/>
<product
id="p4" name="Foxtrot" price="1500" stock="5"/>
<product
id="p5" name="Tango" price="1225" stock="3"/>
</products>
import_1-stylesheet.xsl
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:import
href="import_extra.xsl"/>
<xsl:output
indent="yes"/>
<xsl:template
match="/">
<PRODUCTS>
<xsl:apply-templates/>
</PRODUCTS>
</xsl:template>
</xsl:stylesheet>
import_1-stylesheet-extra.xsl
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template
match="product">
<PRODUCT
id="{@id}" price="{@price}" stock="{@stock}"/>
</xsl:template>
</xsl:stylesheet>
import_1-output.xml
<?xml version="1.0" encoding="UTF-8"?>
<PRODUCTS>
<PRODUCT
id="p1" price="3250" stock="4"/>
<PRODUCT
id="p2" price="1000" stock="5"/>
<PRODUCT
id="p3" price="1200" stock="19"/>
<PRODUCT
id="p4" price="1500" stock="5"/>
<PRODUCT
id="p5" price="1225" stock="3"/>
</PRODUCTS>
xsl:import works exactly like xsl:include except that xsl:import must be the first child under xsl:stylesheet. For that reason templates in the importing stylesheet will always come last and get their way, if we have conflicts between templates matching with same priority.
Updated 2009-03-19