Announcement

Collapse
No announcement yet.

externe XSD (Docbook) in XSD einbinden

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • externe XSD (Docbook) in XSD einbinden

    Hallo zusammen,

    ich möchte mir eine XSD-Datei definieren basierend auf dem Element para der Dockbook-XSD-Datei (http://docbook.org/xml/5.0/xsd/docbook.xsd). Leider schaffe ich es nicht in meiner XSD-Datei Elemente aus der Docbook-XSD-Datei aufzurufen:

    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    	elementFormDefault="qualified"
    	targetNamespace="http://hso.biotronik.com/documentation"
    	xmlns:documentation="http://hso.biotronik.com/documentation">
    	
    	<!--add schema with different target namespace-->
    	<xs:import namespace="http://docbook.org/xml/5.0/xsd" schemaLocation="docbook.xsd"/>
    	
    	<xs:element name="report-article">
    		<xs:complexType>
    			<xs:sequence>
    				<xs:element ref="documentation:long-description" minOccurs="1" maxOccurs="1" />
    				<xs:element ref="documentation:customer" maxOccurs="1" minOccurs="1" />
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>
    
    	<xs:element name="long-description">
    		<xs:annotation>
    			<xs:documentation>long description of the report (purpose, result, data processing)</xs:documentation>
    		</xs:annotation>
    		<xs:complexType>
    			<xs:sequence>
    				<xs:element name="docbook-para" maxOccurs="unbounded" minOccurs="1" />
    				<xs:element ref="documentation:algorithm" maxOccurs="1" minOccurs="1" />
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>
    	<xs:element name="algorithm" type="documentation:docbookParaType">
    		<xs:annotation>
    			<xs:documentation>description of the used algorithm</xs:documentation>
    		</xs:annotation>
    	</xs:element>
    	<xs:element name="customer" type="documentation:docbookParaType">
    		<xs:annotation>
    			<xs:documentation>
    				recipient/s of the report
    			</xs:documentation>
    		</xs:annotation>
    	</xs:element>
    	
    	<xs:complexType name="docbookParaType">
    		<xs:sequence>
    			<xs:element ref="documentation:docbook-para" maxOccurs="unbounded" minOccurs="1" />
    		</xs:sequence>
    	</xs:complexType>
    	
    	<xs:element name="docbook-para" type="docbook:para"/>
    
    </xs:schema>
    Leider kann der Typ docbookara (Typ des letzten Elements docbook-para) nicht gefunden werden:

    Code:
    s4s-att-invalid-value: Invalid attribute value for 'type' in 
     element 'element'. Recorded reason: UndeclaredPrefix: 
     Cannot resolve 'docbook:para' as a QName: the prefix 
     'docbook' is not declared.
    Ist es überhaupt möglich, Elemente aus einer fremden XSD-Datei in einer eigenen XSD-Datei zu referenzieren? Falls dies möglich ist, dann würde ich mich über eine Minimalanleitung freuen.

    Vielen Dank
    Eure Aness
    Zuletzt editiert von aness; 16.02.2011, 17:53.

  • #2
    Du musst in deinem Schema einen Präfix für den Docbook-Namensraum definieren und dann kannst du Elemente aus dem Docbook-Schema per xs: element ref einbinden:
    Code:
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    	elementFormDefault="qualified"
    	targetNamespace="http://hso.biotronik.com/documentation"
    	xmlns:documentation="http://hso.biotronik.com/documentation"
            xmlns:db="http://docbook.org/xml/5.0/xsd">
    	
    	<!--add schema with different target namespace-->
    	<xs:import namespace="http://docbook.org/xml/5.0/xsd" schemaLocation="docbook.xsd"/>
    
            <xs:element name="foo">
               <xs:complexType>
                  <xs:sequence maxOccurs="unbounded">
                    <xs:element ref="db:para"/>
                   </xs:sequence>
                </xs:complexType>
             </xs:element>
    </xs:schema>

    Comment

    Working...
    X