Avatar billede rasmuslh Nybegynder
10. marts 2004 - 11:11 Der er 2 kommentarer og
1 løsning

Validering af Schema med Xerces

Hejsa når jeg prøver at validere mit Schema får jeg følgende fejl:

[Error] ITUblog.xsd:89:26: src-resolve.4: Components from namespace 'http://www.w3.org/2001/XMLSchema' are not referenceable from schema document 'file:///C:/xerces/ITUblog.xsd'.
[Error] blog.xml:26:15: cvc-complex-type.2.4.a: Invalid content starting with element 'author'. The content must match '(EMPTY,EMPTY,EMPTY)'.
[Error] blog.xml:28:13: cvc-complex-type.2.4.a: Invalid content starting with element 'text'. The content must match '(EMPTY,EMPTY,EMPTY)'.
[Error] blog.xml:40:15: cvc-complex-type.2.4.a: Invalid content starting with element 'author'. The content must match '(EMPTY,EMPTY,EMPTY)'.
[Error] blog.xml:42:13: cvc-complex-type.2.4.a: Invalid content starting with element 'text'. The content must match '(EMPTY,EMPTY,EMPTY)'.

Er der nogen der kan hjælpe mig med at forklare hvad de betyder!

På forhånd tak!
Rasmus
Avatar billede arne_v Ekspert
10. marts 2004 - 11:14 #1
Din XML passer ikke til din XSD.

Hvis du poster begge kan vi sikkert se hvorfor.
Avatar billede rasmuslh Nybegynder
10. marts 2004 - 13:44 #2
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:blog="http://www.itu.dk/blog"
    targetNamespace="http://www.itu.dk/blog"
        elementFormDefault="qualified">

<element name="blog">
    <complexType>
      <sequence>
        <element name="author"/>
        <element name="entry" minOccurs="0" maxOccurs="unbounded"/>
      </sequence>
    </complexType>
  </element>


<element name="author">
  <complexType mixed="true">
      <sequence>
        <element name="name" minOccurs="0" maxOccurs="1"/>
            <element name="email" minOccurs="0" maxOccurs="1"/>
      </sequence>
      </complexType>
    </element>

<element name="name">
    <simpleType>
        <restriction base="string">
            <pattern value="[a-zA-Z ]+"/>
        </restriction>
    </simpleType>
</element> 


<element name="email">
    <simpleType>
        <restriction base="string">
            <pattern value="[^@ ]+[@][^@ ]+[^@ ]"/>
        </restriction>
    </simpleType>
</element>




  <element name="entry">
          <complexType>
        <sequence>
              <element name="date"/>
              <element name="title" type="string"/>
                <element name="text"/>
                <element name="reply" minOccurs="0" maxOccurs="unbounded"/>
        </sequence>
      </complexType>
    </element>


<element name="date">
    <complexType>   
              <attribute name="day" type="positiveInteger" use="required"/>
              <attribute name="month" type="positiveInteger" use="required"/>
              <attribute name="year" type="positiveInteger" use="required"/>
  </complexType>
</element>


  <element name="text">
          <complexType mixed="true">
      <sequence>
        <element name="paragraph" minOccurs="0" maxOccurs="unbounded"/>
      </sequence>
      </complexType>
    </element>

<element name="paragraph">
        <complexType mixed="true">
            <choice minOccurs="0" maxOccurs="unbounded">
                <element name="link"/>
                <element name="bold"/>
                <element name="image"/>
            </choice>
        </complexType>
    </element>


<element name="reply">
          <complexType>
      <sequence>
        <element ref="author"/>
        <element ref="date"/>
        <element ref="text"/>
      </sequence>
      </complexType>
    </element>


</schema>


<?xml version="1.0" encoding="UTF-8"?>

<blog xmlns="http://www.itu.dk/blog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.itu.dk/blog ./ITUblog.xsd">

<author>
    <name>Michael Schwartzbach</name>
    <email>mis@brics.dk</email>
  </author>
  <entry>
    <date day="16" month="02" year="2004"/>
    <title>XPath Lecture at ITU</title>
    <text>
      <paragraph>
        Today I lectured on
        <link url="http://www.brics.dk/~amoeller/XML/linking/index.html">XPath</link>.
        which is a <bold>very</bold> useful topic.
      </paragraph>
      <paragraph>
        Look at the child axis here:
        <image url="http://www.brics.dk/~amoeller/XML/linking/child.jpg"/>
      </paragraph>
    </text>
    <reply>
      <author>Thomas Hildebrandt</author>
      <date day="17" month="02" year="2004"/>
      <text>
        Wow, what a nice picture! It looks a little bit like a house.
      </text>
    </reply>
  </entry>
  <entry>
    <date day="23" month="02" year="2004"/>
    <title>XQuery Lecture at ITU</title>
    <text>
      I was very cold today.
    </text>
    <reply>
      <author>Thomas Hildebrandt</author>
      <date day="24" month="02" year="2004"/>
      <text>
        Today the weather is nice. Great day to look at houses!
      </text>
    </reply>
  </entry>
</blog>

:D
Avatar billede rasmuslh Nybegynder
31. marts 2005 - 11:01 #3
luk
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester