Altova StyleVision 2024 Enterprise Edition

If an XML signature is embedded in the XML document, a Signature element in the namespace http://www.w3.org/2000/09/xmldsig# is added to the XML document. In order for the document to remain valid according to a schema, the schema must contain the appropriate element declarations. StyleVision embeds signatures within the document. The signature is said to be Enveloped. The Signature element is created as the last child element of the root (or document) element.

 

If you do not wish to modify the schema of the XML document, the XML signature can be created in an external file. For more details, see the description of the placement options in the section, XML Signature Settings.

 

Given below are excerpts from XML Schemas that show how the Signature element of an enveloped signature can be allowed. You can use these examples as guides to modify your own schemas.

 

In the first of the two listings below, the XML Signature Schema is imported into the user's schema. The XML Signature Schema is located at the web address: http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd

 

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

          xmlns:xsig="http://www.w3.org/2000/09/xmldsig#"

          elementFormDefault="qualified"

          attributeFormDefault="unqualified">

  <xs:import namespace="http://www.w3.org/2000/09/xmldsig#"

             schemaLocation="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"/>

  <xs:element name="Root">

     <xs:complexType>

         <xs:sequence>

            <xs:element ref="FirstChildOfRoot"/>

            <xs:element ref="SecondChildOfRoot" minOccurs="0"/>

            <xs:element ref="ThirdChildOfRoot" minOccurs="0"/>

            <xs:element ref="xsig:Signature" minOccurs="0"/>

         </xs:sequence>

      </xs:complexType>

   </xs:element>

  ...

</xs:schema>

 

A second option (listing below) is to add a generic wildcard element which matches any element from other namespaces. Setting the processContents attribute to lax causes the validator to skip over this element—because no matching element declaration is found. Consequently, the user does not need to reference the XML Signatures Schema. The drawback of this option, however, is that any element (not just the Signature element) can be added at the  specified location in the XML document without invalidating the XML document.

 

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

          elementFormDefault="qualified"

          attributeFormDefault="unqualified">

  <xs:element name="Root">

     <xs:complexType>

         <xs:sequence>

            <xs:element ref="selection"/>

            <xs:element ref="newsitems" minOccurs="0"/>

            <xs:element ref="team" minOccurs="0"/>

            <xs:any namespace="##other" minOccurs="0" processContents="lax"/>

         </xs:sequence>

      </xs:complexType>

   </xs:element>

  ...

</xs:schema>

 

W3C Specification

For more details about XML signatures, see the W3C specification for XML signatures at http://www.w3.org/TR/xmldsig-core/.

 

© 2017-2023 Altova GmbH