Hi,

 

I’m using XSL and Saxon B 8.7.3 to make some minor modifications to a large number of XML documents and I use the following line to copy all of the attributes into each element of the new converted document.

 

    <xsl:copy-of select="@*" />

 

These documents are validated by a schema and many of the element attributes have default values defined for them by the schema. For a given element, if an attribute value does not need to be modified from the default value, that attribute should not be set in either the original or converted element.

 

The problem I’m having is that all attributes with default values are being included with the <xsl:copy-of> tag above, even those that were not set in the original XML. For example in the original XML a para element might look like:

 

                <para>This is a para.</para>

 

But after conversion it then has an unwanted attribute added:

 

                <para verbose=”yes”>This is a para.</para>

 

If an attribute value is not set in the original xml I do not want it included in the output, is there any way to do this? I don’t know of any way to do this with straight XSL, I’m hoping that Saxon has some functions that will tell me if the attribute was actually set or if it’s just being set to the default value. Any help here would be appreciated.

 

Thanks

David Vanfleet