简体   繁体   中英

XML Schema Definition (XSD) for XML files

How can I check whether a XML file uses a XML Schema Definition (XSD)? For example, if you decompress a signed odt file (LibreOffice or OpenOffice text document), in the directory META-INF is the signaturefile documentsignatures.xml . In this file the attribute xmlns defines a default namespace for the elements <Signature> and <document-signatures> . There is neither a reference by the attribute xmlns:xsi to the XML Schema Instance (XSI) namespace "http://www.w3.org/2001/XMLSchema-instance" nor a reference by the attribute xsi:schemaLocation to the XML schema file xmldsig-core-schema.xsd . As a result, the entire content of the documentsignatures.xml file should not be validated under any scheme. Is that correct?

Here are the first lines of the correspnding XML document documentsignatures.xml :

<?xml version="1.0" encoding="UTF-8"?>
<document-signatures xmlns="urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0">
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#" Id="ID_006900630020002d0084000e004a008b009b00a6006f004b007c007b002d007f">
        <SignedInfo>...

Greetings

Kaleun

"...How can I check whether a XML file uses a XML Schema Definition (XSD)?..."

(1) You cannot, if there is no embedded reference in an XML file by the attribute xsi:schemaLocation to the XML schema.

(2) Though, whatever API is in use, it can still validate against some XSD schema that is not mentioned in the actual XML file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM