XML Schema that allows anything (xsd:any) -
i need example of xml schema allow , everything.
it might sound weird this, need debug current schema. thing have complex object use in function (part of dll have no control over) along schema, , functions returns me xml. function throws exception because there's error while validating schema, there shouldn't one. so, want blank schema, schema not cause validation error, can see xml outputted function.
i tried take current schema, , keep xs:schema tag create empty schema, didn't work.
xml schema cannot specify document valid regardless of content.
however, if you're able specify root element, can use xs:anyattribute
, xs:any
allow attributes on root element , xml under root:
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="root"> <xs:complextype> <xs:sequence> <xs:any processcontents="skip" minoccurs="0" maxoccurs="unbounded"/> </xs:sequence> <xs:anyattribute processcontents="skip"/> </xs:complextype> </xs:element> </xs:schema>
in case, long can assured of finite number of possible root element names, can use technique allow xml content under root element known name.
update: can written more concisely [credit: c. m. sperberg-mcqueen]:
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="root"/> </xs:schema>
note allowing, but not requiring, root
empty.
Comments
Post a Comment