110 likes | 215 Views
Compatibility of XML Language Versions Daniel Dui d.dui@cs.ucl.ac.uk March 2003. What is a language?. Definition. Instance. Schema. <class> <subject> Maths <subject> <teacher> Mr Garrison </teacher> <student> Cartman </student> <student> Kyle </student> <student> Sten </student>
E N D
Compatibility of XML Language Versions Daniel Dui d.dui@cs.ucl.ac.uk March 2003
What is a language? Definition Instance Schema <class> <subject>Maths<subject> <teacher>Mr Garrison</teacher> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <subject>English<subject> <teacher>Mr Garrison</teacher> <assistant>Mr Slave</assistant> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> Constraints Rule: If the value of element subject is “English” or “French”, then element assistant shall exist.
Evolution • What happens when the language definition changes? • How can compatibility with previous versions of the language be preserved? • What to do when compatibility can not be preserved?
<class> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <student>Cartman</student> <teacher>Mr Garrison</teacher> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <student>Cartman</student> <teacher>Mr Garrison</teacher> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <teacher>Mr Garrison</teacher> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> Language compatibility Language B is fully compatible with language A
<class> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <student>Cartman</student> <teacher>Mr Garrison</teacher> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <student>Cartman</student> <teacher>Mr Garrison</teacher> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <teacher>Mr Garrison</teacher> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> Incompatible languages Language B is incompatible with language A
Transformations <class> <teacher>unknown</teacher> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class> <class> <student>Cartman</student> <student>Kyle</student> <student>Sten</student> <student>Kenny</student> </class>
Checking compatibility • Schema languages are context free grammars. • Containment and intersection are undecidable operations. But… • There are heuristic compatibility rules for many (most?) practical situations.
Compatibility rules <xsd:element name="class"> <xsd:complextype> <xsd:sequence> <xsd:element name="teacher" type="xsd:string" minOccurs="1" maxOccurs="1" /> <xsd:element name="student" type="xsd:string" minOccurs="1" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complextype> </xsd:element> <xsd:element name="class"> <xsd:complextype> <xsd:sequence> <xsd:element name="teacher" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="student" type="xsd:string" minOccurs="1" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complextype> </xsd:element> <forall var="a" in="/Schema_A//element"> <forall var="b" in="/Schema_B//element"> <implies> <equals op1="$a/@name" op2="$b/@name" /> <and> <equals op1="$a/@type" op2="$b/@type" /> <and> <lessThanOrEq op1="$b/@minOccurs" op2="$a/@minOccurs" /> <greaterThanOrEq op1="$b/@maxOccurs" op2="$a/@maxOccurs" /> </and> </and> </implies> </forall> </forall>
Constraint compatibility Rule A: If the value of element subject is “English” or “French”, then element assistant shall exist. <forall var=”a” in=“//class”> <implies> <or> <equals op1=“$a/subject/text()” op2=“’English’” /> <equals op1=“$a/subject/text()” op2=“’French’” /> </or> <exists var=“b” in=“$a/assistant” /> <implies> <forall> Rule B: If the value of element subject is “English”, then element assistant shall exist. <forall var=”a” in=“//class”> <implies> <equals op1=“$a/subject/text()” op2=“’English’” /> <exists var=“b” in=“$a/assistant” /> <implies> <forall> Compatibility: If second child of implies in Rule A and second child of implies in Rule B are the same, then the first child of implies in Rule A shall be stronger than the first child or implies in Rule B. <implies> <equal op1="$a/child::*[position()=2]“ op2="$b/child::*[position()=2]"> <stronger op1="$a/child::*[position()=1]“ op2="$b/child::*[position()=1]"> </implies>
Coming next Imminent • Schema compatibility rules Next • Constraint compatibility rules Later on • Transformations