Search code examples
xmlxsdxml-dsig

Large number failing validation as type xs:integer


If I try and validate the following XML:

 <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
      <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
      <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
      <Reference URI="#Id-6fa82551-828a-4d41-ab07-02f6887e32a1">
        <Transforms>
          <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
        </Transforms>
        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
        <DigestValue>YZR2p1r5yr4m5vO3ZiK51UCt0n4=</DigestValue>
      </Reference>
    </SignedInfo>
    <SignatureValue>aPY/qeVV5nNCidTlEfB2uiUdg6UtRwRa2/Eqtmcg89P2RkIYl+n+WJ9LbnleGnLwvn8PDe24cRZqxesIFZEs4hVdzxFpFiMVLNaP4etER/k9fzZmcDS8OxtPgkRst6dS2hf2HJA3B2BCpMMCvSb2UAuTGMZAKFeLdfFZiFgCFm08iGLBQ54xML26f0vaOHLoF5fa0XPMq3OkAKwSHw9/mzpzUFGaaIdzj/qiHKJy5uxLEjMt4/FSu44rEHAxziHnyBo7CYsRK1SvwYUhxDEU+TqBOGvFTUqh8qCWzKkhgURjq5gwWd2qYrV7AXkcs5fXXxBH8w9Mnx7C1GHk05ssNQ==</SignatureValue>
    <KeyInfo>
        <X509Data>
          <X509IssuerSerial>
            <X509IssuerName>CN=sbsp3800jcc.office.sbs</X509IssuerName>
            <X509SerialNumber>153921637767027919309545657592381534070</X509SerialNumber>
          </X509IssuerSerial>
        </X509Data>          
    </KeyInfo>
</Signature>

Against the xmldsig-core-schema.xsd schema (can be found easily on the internet), then I get the following validation error:

Validation of current file using XML schema:


ERROR: Element '{http://www.w3.org/2000/09/xmldsig#}X509SerialNumber': '153921637767027919309545657592381534070' is not a valid value of the atomic type 'xs:integer'.

However, many posts I've found on the internet lead me to believe that the xs:integer type should support unlimited number of characters. So, is my validation misbehaving? I have tried 2 different validation techniques now - first, the .NET System.Xml libraries (XmlReader) and secondly, the XML plugins for Notepad++. Both fail with the same message. Are they both wrong? Or, is there in fact a limit on the size that xs:integer values can take?


Solution

  • xs:integer is a restriction of xs:decimal (no fractional part). The decimal spec says

    decimal has a lexical representation consisting of a finite-length sequence of decimal digits

    So in theory there is no limitation on the number of digits.

    BUT the spec contains a note about minimally conforming processors which are allowed to support as few as 18 digits. (Your integer has 39 digits.) It seems that the processors you tried are just ones of those minimally conforming while Xerces and Saxon-EE (according to comment of Daniel Haley) are not.

    Although the spec says that the limitation of digits of such processors should be clearly documented it seems it is not according to this forum post.

    BTW you can validate online via XML Validator on freeformatter.com. It validates your example document.