Frage

I want to define XML which has the ability to link images from within it. I found that it is possible with XLink. But I can't find how to import/include correct XSD.

The following XSD does not validate:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns="http://www.inthemoon.ru/2013/Celebrity"

    targetNamespace="http://www.inthemoon.ru/2013/Celebrity">

    <xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="http://www.w3.org/1999/xlink.xsd"/>

    <xs:element name="celebrities">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="celebrity" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:all>
                            <xs:element name="names">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element maxOccurs="unbounded" name="name"
                                            type="xs:string"/>
                                    </xs:sequence>
                                    <xs:attribute name="lang" type="xs:string"/>
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="images">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element name="image">
                                            <xs:complexType>
                                                <xs:attribute name="href" type="xlink:href"/>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                        </xs:all>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
War es hilfreich?

Lösung

Use <xs:attribute ref="xlink:href"/>.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top