Create two attribute sets
File: Data.xml
<?xml version="1.0"?>
<?xml-stylesheet href="Transform.xslt" type="text/xsl"?>
<message>test</message>
File: Transform.xslt
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:attribute-set name="para">
<xsl:attribute name="doc:style"
namespace="http://www.java2s.com/documents">classic</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="paragraph">
<xsl:attribute name="priority">medium</xsl:attribute>
<xsl:attribute name="date">2003-09-23</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="/">
<xsl:element name="paragraph" use-attribute-sets="para">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="UTF-8"?>
<paragraph xmlns:doc="http://www.java2s.com/documents" doc:style="classic">test</paragraph>
Related examples in the same category