Re: [xml] support for xml schema in libxml2



Hi Kasimier,
  thanks for your hints. In the meantime I did an update for the
XML libraries and I found some new interface functions allowing the attachement of the schema to the XMLReader. So the validation for the XML file works now.
I have still the problem with the default/fixed attributes.

You wrote:

However, adding default or fixed attributes to the validated instance,
regardless if it's a node tree or processed with a stream-based
technique, is not stated by the W3C XML Schema specification.
What you really want is PSVI (http://www.w3.org/TR/xmlschema-1/), which
would allow to lookup default/fixed attributes. Currently PSVI is
not supported. Additionally, I wonder how we should provide PSVI
with a streaming API?
But we added the automatic creation of default/fixed attributes for
the non-streaming API, so if you would be so kind and investigate
if it's possible with Libxml2 to fire additional xml-reader events
for default/fixed attribute, then this would be a good first step
to have it implemented.
What means
" fire additional xml-reader eventsfor default/fixed attribute" ?
What I do is a something comparable to the example reader2.c

  if (reader != NULL) {
       ret = xmlTextReaderRead(reader);
       while (ret == 1) {
           processNode(reader);
           ret = xmlTextReaderRead(reader);
       }





I think it is the best if I try to explain what I want to do, probably you see another
way so solve the problem.

(1) On a low level schema I define a fixed number element types.

Example:

<!-- the int entity -->
<xs:complexType name="intData">
  <xs:complexContent>
     <xs:extension base="icm:basicData">
        <xs:attribute name="val" type="xs:int" use="required" />

<!-- for type recognition, but it currently does not work --> <xs:attribute name="t" type="xs:string" default="ICM_int"/>
     </xs:extension>
  </xs:complexContent>
</xs:complexType>

(2) On a higher level schema I want to use this type for a new element definition.

Example:

<xs:element name="version" type="icm:intData"/>


(3) Within the XML file  I want to write something like that

 <icm:version   val=0    />

!!!!  Scanning the XML file I want to know which low level type I have.
This is to be t="ICM_int". Of course I could write

      <icm:version   val=0   t="ICM_int"  />
      But this is what I wanted to avoid.
If the deault/fixed attributes will not be inserted by the parser, do you see another
       way how to get the type information when scanning the
      <icm:version   val=0    />  line
      line.

Thanks in advance
Manfred








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]