Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6558081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:09:19+00:00 2026-05-25T13:09:19+00:00

I have this schema: <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:simpleType name=errorType> <xs:restriction base=xs:decimal> <xs:totalDigits

  • 0

I have this schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="errorType">
        <xs:restriction base="xs:decimal">
            <xs:totalDigits value="28"/>
            <xs:fractionDigits value="16"/>
            <xs:minExclusive value="0"/>
            <xs:maxExclusive value="1000000000000"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="TEST">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="newElement" type="errorType" minOccurs="1" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

And have this xml:

<?xml version="1.0" encoding="UTF-8"?>
<TEST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <newElement>123456789012.5000000000000003</newElement>
    <newElement>12345678901.5000000000000003</newElement>
    <newElement>1234567890.5000000000000003</newElement>
    <newElement>123456789.5000000000000003</newElement>
    <newElement>123456789.1234567890123456</newElement>
    <newElement>123456789.500000000000003</newElement>
    <newElement>1234567890.500000000000003</newElement>
    <newElement>12345678901.500000000000003</newElement>
    <newElement>123456789012.50000000000003</newElement>

</TEST>

if I validate it using php DOMDocument schemaValidate function i get an error on decimal numbers greater than 27 digits total. Is there any way to overcome this problem?

Complete code:

<?php


function libxml_display_error($error)
{
    $return = "<br/>\n";
    switch ($error->level) {
        case LIBXML_ERR_WARNING:
            $return .= "<b>WARNING:</b> $error->message ";
            break;
        case LIBXML_ERR_ERROR:
            $return .= "<b>ERROR:</b> $error->message ";
            break;
        case LIBXML_ERR_FATAL:
            $return .= "<b>FATAL:</b> $error->message ";
            break;
    }
    $return .= " on line <b>$error->line</b>\n";
    return $return;
}

function libxml_display_errors() {
    $errors = libxml_get_errors();
    foreach ($errors as $error) {
        print libxml_display_error($error);
    }
    libxml_clear_errors();
}

$xsd = '<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="errorType">
        <xs:restriction base="xs:decimal">
            <xs:totalDigits value="28"/>
            <xs:fractionDigits value="16"/>
            <xs:minExclusive value="0"/>
            <xs:maxExclusive value="1000000000000"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="TEST">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="newElement" type="errorType" minOccurs="1" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>';

$xml ='<?xml version="1.0" encoding="UTF-8"?><TEST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <newElement>123456789012.5000000000000003</newElement>
    <newElement>12345678901.5000000000000003</newElement>
    <newElement>1234567890.5000000000000003</newElement>
    <newElement>123456789.5000000000000003</newElement>
    <newElement>123456789.1234567890123456</newElement>
    <newElement>123456789.500000000000003</newElement>  <!-- VALID -->
    <newElement>1234567890.500000000000003</newElement>
    <newElement>12345678901.500000000000003</newElement>
    <newElement>123456789012.50000000000003</newElement>
</TEST>
';
    libxml_use_internal_errors(true);
    $xmlObj = new DOMDocument();
    $xmlObj->loadXML($xml);
    $xmlObj->schemaValidateSource($xsd) ;
print_r (libxml_display_errors());
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:09:20+00:00Added an answer on May 25, 2026 at 1:09 pm

    a) change this label to whatever value you like

    <xs:totalDigits value="28"/>
    

    b) round the numbers to be smaller than the restriction (probably your numbers are 29 digits including the decimal point)

    just acomplish any restriction that the schema requires

    <xs:restriction base="xs:decimal">
                <xs:totalDigits value="28"/>
                <xs:fractionDigits value="16"/>
                <xs:minExclusive value="0"/>
                <xs:maxExclusive value="1000000000000"/>
    </xs:restriction>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this XML <?xml version=1.0 encoding=utf-8?> <root> <xsd:schema id=root xmlns= xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:msdata=urn:schemas-microsoft-com:xml-msdata> <xsd:import
i have this xml schema <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns=http://hidden/abc xmlns:xs=http://www.w3.org/2001/XMLSchema targetNamespace=http://hidden/abc elementFormDefault=qualified attributeFormDefault=unqualified
I have a Xml-Schema file to validate xml-Files. Xml-Schema: <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema
I have following XML schema: <?xml version=1.0 encoding=UTF-8 standalone=no?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=content type=contentType/>
If I have a schema like this: <?xml version=1.0 encoding=utf-8?> <xs:schema targetNamespace=http://mysticwarlords.kaa/XMLSchema xmlns=http://mysticwarlords.kaa/XMLSchema xmlns:xs=http://www.w3.org/2001/XMLSchema>
I have xml file like this <?xml version=1.0 encoding=UTF-8?> <specification xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=file://Desktop/normal.xsd> <university> <refstr>bdvl_te_skrm_stc</refstr>
I'm using an .xsd schema like this <?xml version=1.0 encoding=utf-8?> <xs:schema id=NewDataSet xmlns= xmlns:xs=http://www.w3.org/2001/XMLSchema
I have something like this: <?xml version=1.0 encoding=utf-8?> <Data> <ConfigDatas> <ArrayOfConfigData xmlns:i=http://www.w3.org/2001/XMLSchema-instance xmlns=http://schemas.datacontract.org/2004/07/BTTest.Models> <ConfigData>
I have this XSLT document : <xsl:stylesheet version=1.0 xmlns:mstns=http://www.w3.org/2001/XMLSchema xmlns=http://www.w3.org/2001/XMLSchema xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns:msdata=urn:schemas-microsoft-com:xml-msdata xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:output
I have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <xs:msgdata xmlns:xs=http://www.myCompany.com

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.