[MarkLogic Dev General] Schema Validation problem

Danny Sokolsky Danny.Sokolsky at marklogic.com
Fri Oct 4 14:33:20 PDT 2013


Below are the schema and XML files (sent off-list, along with the fact that he is running 6.0-2.3).

Andres, 3 things to think about here:  1) I don't see a target namespace in your schema documents.  2) your XML document is in no namespace.   3) have you tried this on 6.0-4?  There were a lot of schema issues fixed between 6.0-2 and 6.0-4.

If you are using schemas, you should really not use no namespace, as it becomes very difficult to work out what is going on.

Here is childs_declaration.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <!--elements-->
  <xs:element name="TermList"/>
  <xs:element name="TermInfo" type="child_elements"/>
  <!--end elements-->
  <!--complexTypes-->
  <xs:complexType name="text_elements" mixed="true">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:group ref="text_elements"/>
    </xs:choice>
  </xs:complexType>
  <!--*********************************-->
  <xs:complexType name="child_elements" mixed="true">
    <xs:choice>
      <xs:sequence maxOccurs="1">
        <xs:element name="T" type="text_elements"/>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:group ref="child_elements"/>
       </xs:choice>
        <xs:element name="ID" type="text_elements"/>
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
          <xs:group ref="child_elements"/>
        </xs:sequence>
      </xs:sequence>
      <xs:sequence maxOccurs="1">
        <xs:element name="ID" type="text_elements"/>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:group ref="child_elements"/>
        </xs:choice>
        <xs:element name="T" type="text_elements"/>
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
          <xs:group ref="child_elements"/>
        </xs:sequence>
      </xs:sequence>
    </xs:choice>
  </xs:complexType>
  <!--complexTypes-->
  <!--groups-->
  <xs:group name="child_elements">
    <xs:choice>
      <xs:element ref="TermInfo" minOccurs="1" maxOccurs="unbounded"/>
      <xs:element ref="TermList"/>
      <xs:element name="QC" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Status" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="UF" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="RT" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="ttm" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="RS" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="TLID" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="CCSSMathText" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="CCSSELAText" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Student-facing_Skill" type="text_elements" minOccurs="0"
        maxOccurs="unbounded"/>
      <xs:element name="Teacher-facing_Skill" type="text_elements" minOccurs="0"
        maxOccurs="unbounded"/>
      <xs:element name="SN" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="CCSS" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="FN" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="EN" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="NN" type="text_elements" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Shortened_Version" type="text_elements" minOccurs="0" maxOccurs="unbounded"
      />
    </xs:choice>
  </xs:group>
  <!--**********************************-->
  <xs:group name="text_elements">
    <xs:choice>
      <xs:element name="i" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="br" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="p" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="u" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="b" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="ul" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="li" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
    </xs:choice>
  </xs:group>
  <!--end groups-->
</xs:schema>

Here is TLele.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:include schemaLocation="childs_declaration.xsd"/>
  <!--elements-->
  <xs:element name="TLela">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="TermInfo"/>
        <xs:element ref="TermList"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

And here is TLela.xml:

<?xml version="1.0" encoding="UTF-8"?>
<TLela>
                <TermInfo>
                                <T>English Language Arts</T>
                                <Status>Accepted</Status>
                                <QC>Y</QC>
                                <NN>1</NN>
                                <ID>ela-737</ID>
                                <TermList>
                                                <TermInfo>
                                                                <T>Alphabet</T>
                                                                <RT>Alphabetical order</RT>
                                                                <Status>Accepted</Status>
                                                                <QC>Y</QC>
                                                                <NN>1.2.1</NN>
                                                                <ID>ela-426</ID>
                                                                <TermList>
                                                                                <TermInfo>
                                                                                                <T>Consonants</T>
                                                                                                <Status>Accepted</Status>
                                                                                                <QC>Y</QC>
                                                                                                <NN>1.2.1.1</NN>
                                                                                                <ID>ela-655</ID>
                                                                                </TermInfo>
                                                                                <TermInfo>
                                                                                                <T>Letters</T>
                                                                                                <Status>Accepted</Status>
                                                                                                <QC>Y</QC>
                                                                                                <NN>1.2.1.2</NN>
                                                                                                <ID>ela-4121</ID>
                                                                                </TermInfo>
                                                                                <TermInfo>
                                                                                                <T>Vowels</T>
                                                                                                <Status>Accepted</Status>
                                                                                                <QC>Y</QC>
                                                                                                <NN>1.2.1.3</NN>
                                                                                                <ID>ela-4834</ID>
                                                                                </TermInfo>
                                                                </TermList>
                                                </TermInfo>
                                </TermList>
                </TermInfo>
</TLela>

-Danny



From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Danny Sokolsky
Sent: Friday, October 04, 2013 1:48 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Schema Validation problem

Hi Andres,

I don't see any schema or xml files attached, so it is hard to comment on it.

Also, what version of MarkLogic are you using (xdmp:version() )?

-Danny

From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Andres Felipe Restrepo Pino
Sent: Friday, October 04, 2013 1:06 PM
To: general at developer.marklogic.com
Subject: [MarkLogic Dev General] Schema Validation problem

Good day,

I'm trying to validate an XML file using an XSD made in Oxygen Editor version 14, At the editor the xsd seems to work according to the requirement, but when I use the "validate strict{$node}" sentence, this is what i got:

1. I validate the schema against to a valid XML, everything its ok in both cases, Oxygen and Marklogic.
2. If I validate against to an invalid XML file using the oxygen editor the error is showed in the console, but doing the same validation in the marklogic console the XML seems to be valid.
3. I try again but this time I modify the XML in the initial node (which is restricted in the xsd) the results seems to be invaled in both consoles.

My xsd file is created with groups, complexTypes, sequences and choices elements.

According to this, the problem seems to be with the XSD proccessor, searching on internet i found that Marklogic only have support for schema 1.0 and Oxygen is working with Schema 1.1, I'm not sure if the problem is because of the schema version.

So, Does Marklogic have problems with this kind of xsd files?, how can I create or is there a Editor to create xsd that Marklogic can manage?

Thanks for the attention,

I attached the xsd and xml files.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20131004/697b8855/attachment-0001.html 


More information about the General mailing list