I started using RelaxNG to specify XML message schemas and using PHP DOMDocument to check and parse incoming messages, but I canβt figure out how to define node text so it cannot be empty. Example circuit:
<?xml version="1.0"?>
<element name="amhAPI" xmlns="http://relaxng.org/ns/structure/1.0">
<element name="auth">
<element name="validateUser">
<element name="username">
<text/>
</element>
<element name="password">
<text/>
</element>
</element>
</element>
</element>
However, the message below is checked using the DOMDocument :: relaxNGValidate method (since relaxng matches any arbitrary string [including the empty one] with the template text) and is equivalent):
<?xml version="1.0"?>
<amhAPI>
<auth>
<validateUser>
<username/>
<password/>
</validateUser>
</auth>
</amhAPI>
Because of this, I need to add a bunch of checks and checks for fields that should not be empty, which can be removed if the validator identified them as non-empty elements.
Is there a way to force non-blank text?
source
share