Yes, that is correct we are doing validation with Xerces not Saxon. We would like to move to the most recent version of Saxon but there was a compatibility issue with XMLBeans, Saxon, and Xerces. One other option we have is to use a schema that does not include the attribute default values. I will try out your solution as soon as I can and let you know if it works for us.

 

Thanks for your quick response,

David Vanfleet

 

From: Michael Kay [mailto:mike@saxonica.com]
Sent: Thursday, November 13, 2008 10:53 AM
To: 'Mailing list for the SAXON XSLT and XQuery processor'
Subject: Re: [saxon] Dealing with default attribute values

 

I just noticed that you are using Saxon-B, which presumably means that the schema validation is being done by Xerces rather than by Saxon. I'm afraid I don't know whether this option will switch off attribute expansion done by the Xerces schema processor. It 's known to work with the Xerces DTD validator and with the Saxon-SA schema validator.

 

Michael Kay

http://www.saxonica.com/

 


From: Michael Kay [mailto:mike@saxonica.com]
Sent: 13 November 2008 17:48
To: 'Mailing list for the SAXON XSLT and XQuery processor'
Subject: Re: [saxon] Dealing with default attribute values

In Saxon 9.1 there's a command line option -expand:off which has the effect you are looking for. It can also be set from the API. It's a relatively recent addition so you'll need to move forward a few versions.

 

Michael Kay

http://www.saxonica.com/

 


From: Vanfleet, David [mailto:david.vanfleet@siemens.com]
Sent: 13 November 2008 17:41
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Dealing with default attribute values

 

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