Jump to content

[Resolvido] Dividir ficheiro XSD


Guest u24563
 Share

Recommended Posts

Guest u24563

Olá!

Sou um principiante em XML e XML Schema e estou aqui com uma dúvida. O que estou a tentar fazer é dividir um ficheiro .xsd em dois e usar o comando <xs:include ...> para fazer a ligação entre eles... No entanto, não estou a conseguir!

Ficheiro XML:

<?xml version="1.0"?>
<university xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Lab3_task4.xsd">
<name>Wroclaw University of Technology - WrUT</name>
<faculties>
 <faculty>
  <name>Faculty of Electronics</name>
  <majors>
   <major name_major="Electronics">
    <description>Electronics major in Faculty of Electronics</description>
    <phone>+48733964774</phone>
    <year>1990</year>
   </major>
   <major name_major="Telecommunications">
    <description>Telecommunications major in Faculty of Electronics</description>
    <phone>+48731654884</phone>
    <year>1992</year>
   </major>
  </majors>
 </faculty>
 <faculty>
  <name>Faculty of Computer Science and Management</name>
  <majors>
   <major name_major="Computer Science">
    <description>Computer Science major in Faculty of Computer Science and Management</description>
    <phone>+48733932234</phone>
    <year>1986</year>
   </major>
   <major name_major="Management">
    <description>Management major in Faculty of Computer Science and Management</description>
    <phone>+48732567894</phone>
    <year>1986</year>
   </major>
  </majors>
 </faculty>
</faculties>
</university>

Ficheiro XSD 1:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://w3schools.com/schema" elementFormDefault="qualified">
<xs:include schemaLocation="Lab3_task4_1.xsd"/>
<xs:element name="university">
<xs:complexType>
 <xs:sequence>
  <xs:element name="name" type="xs:string"/>
  <xs:element name="faculties">
   <xs:complexType>
    <xs:sequence>
     <xs:element name="faculty" type="FacultyType" maxOccurs="unbounded"/>
    </xs:sequence>
   </xs:complexType>
  </xs:element>
 </xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Ficheiro XSD 2:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://w3schools.com/schema" elementFormDefault="qualified">
<!-- definition of some complex elements -->
<xs:element name="major">
<xs:complexType>
 <xs:sequence>
  <xs:element name="description" type="xs:string"/>
  <xs:element name="phone" type="xs:integer"/>
  <xs:element name="year" type="xs:integer"/>
 </xs:sequence>
 <xs:attribute name="name_major" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:complexType name="FacultyType">
<xs:sequence>
 <xs:element name="name" type="xs:string"/>
 <xs:element name="majors">
  <xs:complexType>
   <xs:sequence>
    <xs:element ref="major" maxOccurs="unbounded"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>

Se me pudessem ajudar a perceber o que está mal e como posso resolver, agradecia imenso 😄

Edited by u24563
GeSHi
Link to comment
Share on other sites

O erro não ajuda muito, e não tenho nenhuma ferramenta à mão que me permita testar isso facilmente. Nos testes que fiz, com tudo num ficheiro para conseguir testar, precisei de adicionar um xmlns="http://www.example.net/test" no xs:schema.

No xs:include em particular não encontrei nenhum erro.

Já conseguiste resolver o problema com tudo num ficheiro?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.