I´m trying to copy an Attribute value from one element in the schema to the XSLT output.
I tried copy-of, and visited a lot of examples with schema-element but it seems only used for matching or copying whole node structures…
Summing up, I would like to take profit of the xslt xsd awareness for doing the equivalent of the Post-Schema-Validation Infosetway of assigning default values to attributes
XML
<MyProject Val="wrongval">
XSD
<xs:element name="MyProject">
<xs:complexType>
<xs:attribute name="Val" fixed="1234" />
</xs:complexType>
</xs:element>
XSLT
<xsl:template match="/">
<xsl:element name="MyProject">
<xsl:attribute name="Val">**???=1234**</xsl:attribute>
</xsl:element>
</xsl:template>
You’re nearly there. Given the following (unused) source document:
and the following schema:
and the following stylesheet:
the transformation output is: