Re: Check two elements are not deep equal

On 28/11/2007, Michael Kay <mike@saxonica.com> wrote:
> In 1.1 - as implemented by Saxon 9.0 - you can do
>
> <xs:assert test="not(deep-equal(old, new))"/>
>
> But if it's as simple as this I think you can also do it in 1.0:
>
> * define that both old and new exist in the usual way
>
> * define at the update level
>
> <xs:unique>
>   <xs:selector xpath="*"/>
>   <xs:field xpath="data1"/>
>   <xs:field xpath="data2"/>
> </xs:unique>

Fantastic - that's brilliant thanks... there are 20 elements is the
real code so the list is a lot longer but it does the job.

One small issue which I can happily live with - two of the elements
are optional (say data3 and data4), and when they don't occur in the
XML I get this error (from Xerces):

org.xml.sax.SAXParseException: Not enough values specified for
<unique> identity constraint specified for element "update".

I've removed the elements from the field list in the unique
constraint, which is fine as they're rare, but if its straightforward
to handle this situation... any ideas?

thanks

Received on Wednesday, 28 November 2007 12:57:15 UTC