문제

I want to validate an XML through XSD. I must mention that my XSD works fine, except this one piece:

<xs:element name="some_element">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:minLength value="50"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>

I made a wrapper PHP class to validate this against an XML and, at it's core, it's doing this:

$dom = new DOMDocument();
$dom->loadXML($xml);

// handle errors manually
set_error_handler(array($this, 'errorHandler'));

// validate
$isValid = $dom->schemaValidateSource($xsd);

// restore default error handler
restore_error_handler();

The problem is that, even on <some_element></some_element> or <some_element>[100_chars_here]</some_element>, it validates (I get no errors), and I would like to have a minimum content length of 50 for that element.

Is there a bug somewhere? What am I missing here? It works with regex patterns in XSD, but I wouldn't want to use those.

I'm using PHP 5.3.5 with libxml 2.7.7 on WinXP.

도움이 되었습니까?

해결책

On the face of it, it looks like a bug, but there's not enough information here to say that with any certainty.

Have you tried running the validation with a different schema processor? That should be your first step if a bug is suspected, as it's likely to confirm it one way or the other.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top