| oraclemike |
| Newbie |
|
| TX |
|
|
| None Specified |
|
| Thursday, August 12, 2010 |
| Monday, August 30, 2010 3:25:04 PM |
8 [0.04% of all post / 0.00 posts per day] |
|
GregK wrote:Right. Importing and redefining at the same time forces construction of equally-named (i.e., duplicate) schema components. This is rationalized by XML Schema 1.0.
Let me ask the question a little differently. It it possible to redefine elements of an imported schema?
Meaning if a schema main imports a schema libs where main is targetnamespace http://www.main.org and libs targetnamespace is http://www.libs.org then I do an redefine from schema red-main of targetnamespace http://www.main.org.
lets say I have a complex element libselement can I do this.
<xs:complexType name = "libs:libselement"> <xs:complexContent> <xs:extension base = "libs:libselement"> <xs:sequence> <xs:element name="Newelmnt" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType>
|
Looks like XML Spy will allow this schema to validate, however I don't know how it should be represented in the background.
I have a schema with one namespace lets call it base, base does an import to schema subschema.
Both base and subschema reference libs:libschema. libschema is a set of commonly used simple and complextypes which are shared by both base and subschema.
As it happens, libschema shares the same targetnamespace as base. Therefore, subschema has to import libs:libschema, where base does an include of libschema.
Here's the crux of my issue, if I create a schema superbase which is a redefine of bs:base and imports subs:subschema, what happens to the references of libs:libschema referenced in subs:subschema?
I did some playing around and found that XMLSpy decides these two references to the same libs:libschema results in collisions. I can references the same namespace in this way.
Is this technically correct for an XML specification standpoint?
References to the same namespace can't be "merged" via a redefine + import(shares the redefine namespace as included via import within the imported namespace) in a super schema?
Regards,
Mike
|
Thanks for the feedback. I guess that's good/bad news. :) Could it be that I have an incorrect setting?
**I gave the latest version a try and it worked. Wonder if there are any patches for V2004?
Regards,
Mike
|
vlad wrote:You missed their point. They are redefining another group, so the reference you see in their sample is not to the group itself but to a different group defined somewhere else.
Vlad,
That's exactly what I'm trying to do, I'm trying to redefine another group, with the same name, from another schema. I didn't include all of the XML, just the redefine XML.
However, when I try to validate in XML Spy it throws the error like it doesn't recognize or doesn't allow the redefine.
This is what I'm trying to understand. Should I include a more complete example?
The 3 schemas below show the error. See the RTLIC in the CRedSchema.xsd. If the name is changed from RTLIC to RTLICx it works fine. I don't know why it won't referenced the RTLIC defined in CBaseRefSchema.xsd.
Regards,
Mike
***Here it goes.*** CBaseRefSchema.xsd ****************** <?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="http://www.test.org/test/namespace/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.test.org/test/namespace/" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:complexType name="PLRT"> <xs:sequence> <xs:element name="SON" type="xs:string" minOccurs="0"/> <xs:element name="MA" type="xs:boolean" minOccurs="0"/> <xs:element name="RDT" type="xs:dateTime" minOccurs="0"/> <xs:element name="TC" type="xs:integer" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:group name="RTLIC"> <xs:choice> <xs:element name="SaleForDelivery" type="xs:string"/> <xs:element name="Sale" type="xs:string"/> <xs:element name="SaleForPickup" type="xs:string"/> </xs:choice> </xs:group> </xs:schema>
****************** CBaseSchema.xsd ****************** <?xml version="1.0" encoding="UTF-8"?> <!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com --> <!-- --> <xs:schema targetNamespace="http://www.test.org/test/namespace/" xmlns="http://www.test.org/test/namespace/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ext="http://www.extend.org/extend/namespace/" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:include schemaLocation="CBaseRefSchema.xsd"/> <!--<xs:import namespace="http://www.test.org/test/namespace/" schemaLocation="refSchema.xsd"/>--> <xs:element name="Whatup" type="WhatupType"/> <xs:complexType name="WhatupType"> <xs:sequence> <xs:element name="RefSCplx" type="PLRT"/> <xs:element name="Smpl" type="xs:string"/> <xs:group ref="RTLIC"/> </xs:sequence> </xs:complexType> </xs:schema>
******** CRedSchema.xsd ******** <?xml version="1.0" encoding="UTF-8"?> <!-- /* =========================================================================== * Example validation failure of redefined complexType referencing a complexType extension * =========================================================================== */ --> <xs:schema targetNamespace="http://www.test.org/test/namespace/" xmlns="http://www.test.org/test/namespace/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:redefine schemaLocation="CBaseSchema.xsd"> <xs:complexType name="PLRT"> <xs:complexContent> <xs:extension base="PLRT"> <xs:sequence> <xs:element name="LT6" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:group name="RTLIC"> <xs:sequence> <xs:group ref="RTLIC"/> <xs:group ref="RTLICExt"/> </xs:sequence> </xs:group> </xs:redefine> <xs:group name="RTLICExt"> <xs:choice> <xs:element name="ExtSale" type="xs:string"/> </xs:choice> </xs:group> </xs:schema>
Regards,
Mike
|
Let me describe what I'm trying to do. I want the ability to define a base group in a reference schema, which would then be included in another schema that could create an extended version of the base group with the same name.
So lets say
GROUP A Element 1 Element 2 Element 3
GROUP A prime Element 1 Element 2 Element 3 Element 4 (This is the new one.)
I'm surprised the syntax would be considered incorrect since I've found samples on the web that do it this way.
Here's an example http://www.datypic.com/books/defxmlschema/chapter18.html link see example Example 18-5.
Regards,
MIke
|
I'm using XML Spy 2004.
I'm having an error where a group defined in an included/redefined schema throws an error.
ERROR THROWN This schema doesn't appear to be valid by itself (...) Schema error mg-props-correct - 'Model/group Correct' Constraint is violated in group 'ABC' Circular groups are disallowed.
I'm trying to do the following:
<xsd:redefine schemaLocation="prod1.xsd"> <!-- This is an existing group defined in "prod1.xsd" --> <xsd:group name="DescriptionGroup"> <xsd:sequence> <xsd:group ref="DescriptionGroup"/> <xsd:element name="notes" type="xsd:string"/> </xsd:sequence> </xsd:group> </xsd:redefine>
Instead of referencing the existing group "DescriptionGroup" defined in schemaLocation="prod1.xsd", it tried to refer to itself circularly.
Any ideas would be much appreciated.
Regards,
Mike
|
|