Avatar billede krukken Juniormester
09. juni 2009 - 17:35 Der er 2 kommentarer og
1 løsning

XSD format for XML

Hej,

Jeg skal bruge en XSD for følgende format:

<steps>
    <step id="1">
      <choices>
        <choice id="3"/>
      </choices>
    </step>
    <step id="2">
      <choices>
        <choice id="2"/>
      </choices>
    </step>
    <step id="3">
      <choices>
        <choice id="2"/>
        <choice id="3"/>
        <choice id="7"/>
        <choice id="10"/>
        <choice id="12"><![CDATA[alt er bare sååå fantastisk!]]></choice>
      </choices>
    </step>
    <step id="4">
      <choices>
        <choice id="1"><![CDATA[totalt helt vildt!]]></choice>
      </choices>
    </step>
  </steps>

Jeg har indtil videre lavet følgende:
<xs:complexType name="Steps">
    <xs:sequence>
      <xs:element name="step" type="Step" minOccurs="1" maxOccurs="1">
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Step">
    <xs:simpleContent>
      <xs:extension base="xs:decimal">
        <xs:attribute name="id" type="xs:string" use="required"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:complexType name="Choice">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="id" type="xs:string" use="required"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
 
  <xs:complexType name="Choices">
    <xs:sequence>
      <xs:element name="choice" type="Choice" maxOccurs="unbounded" minOccurs="1"></xs:element>
    </xs:sequence>
  </xs:complexType>
Avatar billede arne_v Ekspert
09. juni 2009 - 18:59 #1
Foelgende ser OK ud for mig:

<steps xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://www.foobar.dk/steps"
      xsi:schemaLocation="http://www.foobar.dk/steps steps.xsd">
    <step id="1">
      <choices>
        <choice id="3"/>
      </choices>
    </step>
    <step id="2">
      <choices>
        <choice id="2"/>
      </choices>
    </step>
    <step id="3">
      <choices>
        <choice id="2"/>
        <choice id="3"/>
        <choice id="7"/>
        <choice id="10"/>
        <choice id="12"><![CDATA[alt er bare sååå fantastisk!]]></choice>
      </choices>
    </step>
    <step id="4">
      <choices>
        <choice id="1"><![CDATA[totalt helt vildt!]]></choice>
      </choices>
    </step>
</steps>


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns="http://www.foobar.dk/steps"
          targetNamespace="http://www.foobar.dk/steps"
          elementFormDefault="qualified">
  <xs:element name="steps" type="Steps"/>
 
  <xs:complexType name="Steps">
    <xs:sequence>
      <xs:element name="step" type="Step" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Step">
    <xs:sequence>
      <xs:element name="choices" type="Choices"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:positiveInteger" use="required"/>
  </xs:complexType>

  <xs:complexType name="Choices">
    <xs:sequence>
      <xs:element name="choice" type="Choice" minOccurs="1" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Choice">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="id" type="xs:positiveInteger" use="required"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

</xs:schema>
Avatar billede arne_v Ekspert
09. juni 2009 - 19:06 #2
Men husk at der er uendeligt mange schemaer til en given XML fil.
Avatar billede arne_v Ekspert
04. august 2009 - 04:02 #3
OK ?
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
Computerworld tilbyder specialiserede kurser i database-management

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