0

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

Kaleun
  • 13
  • 3

1 Answers1

0

"...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.

Yitzhak Khabinsky
  • 18,471
  • 2
  • 15
  • 21
  • That helped me a lot, thanks :) I took a closer look at [xmldsig-core-schema.xsd](http://www.w3.org/2000/09/xmldsig#). Pretty much at the beginning (in the 12th line) is written down: ``````. Since ```maxOccurs``` is not specified, this value is set to 1 by default, which means that the `````` element may only appear once. If I now copy the complete `````` element behind it and I check the signature, it will be invalid. Could this be taken as an indication that the file _documentsignatures.xml_ is validated under a schema? – Kaleun Feb 13 '20 at 17:14
  • Instead of guessing, you can try to validate the XML file in question against the XSD by following (2) approach. – Yitzhak Khabinsky Feb 13 '20 at 17:18
  • Yes, I can check that. But then I still don't know whether the ODF implementations LibreOffice or OpenOffice use an XSD. I get the indication that the signature is invalid by using LibreOffice or OpenOffice. – Kaleun Feb 13 '20 at 17:30