XML Schema: 1) two levels of schemas and 2) code complete

Having trouble installing Oxygen? Got a bug to report? Post it all here.
kilhor
Posts: 15
Joined: Thu Jun 10, 2004 1:51 pm
Location: ETH Zurich, Switzerland

XML Schema: 1) two levels of schemas and 2) code complete

Post by kilhor »

Hello!

Background: My overall goal is to develop XML Schema (http://control.ee.ethz.ch/~rohliko/xml/ ... MMFFMM.xsd) for domains-specific XML Schemas (e.g. http://control.ee.ethz.ch/~rohliko/xml/ ... CSR.schema). I tried to follow the hints given in the article at http://www.xml.com/pub/a/2002/10/02/metaschema.html. However, I found it difficult to express what I need using the <xs:redefine> element. Therefore I decided first to do the job by modifying directly the (errated) XML Schema definition (from http://www.w3.org/2001/XMLSchema.xsd ... thanks to george for pointing me there). Other references to my prevouis problem is at http://www.oxygenxml.com/forum/ftopic556.html (now solved, thanks).

What I did is that I introduced new attribute to the <xs:complexType> element -- the attribute is called "displayType" and can have six different values. An exemple of this can be seen in FeatureMetamodelCSR.schema. This file is valid against XMLSchemaOfMMFFMM.xsd. Now the strange thing: When I open new file that I want to validate against ("valid") FeatureMetamodelCSR.schema and write the following code ...

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<FeatureModel name="InstanceOfICSR"
xmlns="http://www.pnp-software.com/fmt/fm"
xmlns:mmffmm="http://www.pnp-software.com/fmt/fm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.pnp-software.com/fmt/fm FeatureMetamodelCSR.schema">

</FeatureModel>
... I get two kind of strange errors. First I get 26 errors concerning the displayType attribute. How it is possible if the FeatureMetamodelCSR.schema itself was validated? Second I get two contradicting errors concerning the name attribute. This errors can be removed by specifying the mmffmm prefix to this attribute, but since there is a default namespace which is the same as the namespace with prefix "mmffmm" there should be no difference, right?

The third question I would like to discuss with others is whether you have some experience with creating schemas for schemas (and also using these schemas) -- i.e exactly the same thing that I describe here. I am fighting it for several week and still do not know how to put things together ... and google has no answers ;-(. Does anybody has some examples or samples that he can share with me? I would be grateful.

The previos question was quite general. Now I have very concrete one. If you write character "<" (less then) right after the closing tag of "FeatureModel" element (just cut and paste the code above) and let the Oxygen make its code complete function (select the first option "FeatureNode") it inserts the following:

Code: Select all


  <FeatureNode xmlns:oXygen1="http://www.pnp-software.com/fmt/fm" oXygen1:name="">
<MultipleCardinality xmlns:oXygen1="http://www.pnp-software.com/fmt/fm" oXygen1:cardMin="" xmlns:oXygen2="http://www.pnp-software.com/fmt/fm" oXygen2:cardMax=""/>
</FeatureNode>
Fourth questions is: What is this? Why there are two prefixes (oXygen1 and oXygen2) for the same namspece, which is BTW the default namespace and also the namespace with prefix "mmffmm"? Moreover, the oXygen1 prefix is used twice for the same namespace (more precisely, it is redefined in the child element). Why Oxygen doesn't offer "mmffmm" or none prefix?

I will appreciate any help from you. Many thanks in advance!

Best regards,
Ondrej
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Ondrej,
First I get 26 errors concerning the displayType attribute. How it is possible if the FeatureMetamodelCSR.schema itself was validated?
When you validated the FeatureMetamodelCSR.schema you performed a check against the XMLSchemaOfMMFFMM.xsd, that is FeatureMetamodelCSR.schema was treated as an instance document. When you validated the sample document against FeatureMetamodelCSR.schema then FeatureMetamodelCSR.schema was processed as an XML Schema file and checked internally by Xerces to be a valid XML Schema file, thus the reported errors because the displayType attribute cannot appear in a complexType element according with the XML Schema specification.
Second I get two contradicting errors concerning the name attribute. This errors can be removed by specifying the mmffmm prefix to this attribute, but since there is a default namespace which is the same as the namespace with prefix "mmffmm" there should be no difference, right?
The contradictory error messages are caused by a bug in Xerces. I filed a bug agaist Xerces some time ago on exactly this problem. See
http://nagoya.apache.org/jira/browse/XERCESJ-819
if you want to track it.
You need to specify a prefix for attributes, otherwise they belong to no namespace. See
http://www.w3.org/TR/REC-xml-names/#defaulting
for more details.
The third question I would like to discuss with others is whether you have some experience with creating schemas for schemas (and also using these schemas) -- i.e exactly the same thing that I describe here.
I have not tried this but I guess that you need to write also a schema validator for the modified schema language.
Fourth questions is: What is this? Why there are two prefixes (oXygen1 and oXygen2) for the same namspece, which is BTW the default namespace and also the namespace with prefix "mmffmm"? Moreover, the oXygen1 prefix is used twice for the same namespace (more precisely, it is redefined in the child element). Why Oxygen doesn't offer "mmffmm" or none prefix?
What happens here is that when oXygen tries to find the prefix associated with the http://www.pnp-software.com/fmt/fm namespace it gets an empty string (from the default namespace) and it cannot use that - see above - as that will set the attribute in no namespace. Therefore it declares a proxy for that namespace and enters the attribute accordingly.
We should however fix this to detect a real prefix if available when we deal with attributes.

Best Regards,
George
Post Reply