Re: Element Substitution
Michael Kay <[email protected]> Mon, 3 May 2021 10:37:21 +0100
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <[email protected]> |
This should validate successfully, and it works for me both running Saxon 10 from the command line, and running Saxon 9.9.1.7 within Oxygen. Probably need to look more carefully at exactly what options you are using when running the Oxygen validation. Michael Kay Saxonica > On 2 May 2021, at 22:35, Paul Mensonides <[email protected]> wrote: > > I am trying to wrap my head around the rules for element substitution in XML Schema, but I am running into some kind of namespace problem. > > [a.xsd] > <?xml version="1.1" encoding="UTF-8"?> > <xs:schema > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" > xmlns:a="urn:a" > targetNamespace="urn:a" > elementFormDefault="qualified" > vc:minVersion="1.1"> > <xs:complexType name="type"> > <xs:sequence> > <xs:element ref="a:element" > minOccurs="0" maxOccurs="unbounded"/> > </xs:sequence> > </xs:complexType> > <xs:element name="element" type="a:type"/> > </xs:schema> > > [b.xsd] > <?xml version="1.1" encoding="UTF-8"?> > <xs:schema > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" > xmlns:a="urn:a" xmlns:b="urn:b" > targetNamespace="urn:b" > elementFormDefault="qualified" > vc:minVersion="1.1"> > <xs:import namespace="urn:a" schemaLocation="a.xsd"/> > <xs:complexType name="type"> > <xs:complexContent> > <xs:extension base="a:type"/> > </xs:complexContent> > </xs:complexType> > <xs:element name="element" type="b:type" > substitutionGroup="a:element"/> > </xs:schema> > > [x.xml] > <?xml version="1.1" encoding="UTF-8"?> > <a:element > xmlns:a="urn:a" xmlns:b="urn:b" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="urn:a a.xsd urn:b b.xsd"> > <b:element/> > </a:element> > > In Saxon 9.9.1.5 (which is the latest I have access to from the command line), this works fine. > > However, in Saxon 9.9.1.7 (which is what my version of Oxygen is using), it fails: > > In content of element <a:element>: The content model does not allow element <Q{urn:b}element> to appear as the first child. The element is in namespace urn:b but it should be in namespace urn:a. > > Note that a:element/a:element, b:element/a:element, and b:element/b:element all work. > > Is there some rule that I am missing? > > Regards, > Paul Mensonides > > > > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [email protected] > https://lists.sourceforge.net/lists/listinfo/saxon-help