Read XML with Schema from Socket with socket\


How to read XML document with XML Schema validation from socket connections with the socket\ provided in the Apache Xerces package?

✍: FYIcenter


If you want to see how XML parser handles XML document with Schema validation from socket connections, you can try the socket\ provided in the Apache Xerces package to display element type information.

Run socket\ with "-v -s" option, if you have Apache Xerces 2.11.0 installed:

   -cp .;..\xercesImpl.jar socket.DelayedInput -v -s UserXsdError.xml
# filename: UserXsdError.xml
read 48 bytes in 458 ms: [\n<!-- Copyright (c) 2017 -->\n<fyi:]
read 48 bytes in 1553 ms: [User xmlns:xsi="]
read 48 bytes in 1486 ms: [-instance"\n  xmlns:fyi=""\n  ]
read 48 bytes in 151 ms: [xsi:schemaLocation=" User.xs]
read 48 bytes in 478 ms: [d">\n    <fyi:ID>ONE</fyi:ID>\n    <fyi:Name>Frank]
Axsi:schemaLocation User.xsd
[Error] UserXsdError.xml:6:25: cvc-datatype-valid.1.2.1: 'ONE' is not a valid va
lue for 'integer'.
[Error] UserXsdError.xml:6:25: cvc-type.3.1.3: The value 'ONE' of element 'fyi:I
D' is not valid.
read 48 bytes in 804 ms: [ Y. Ivy</fyi:Name>\n    <fyi:BirthDate>1970-01-01]
read 48 bytes in 1246 ms: [+00:01</fyi:BirthDate>\n    <fyi:Sex>  Male</fyi:]
[Error] UserXsdError.xml:8:52: cvc-datatype-valid.1.2.1: '1970-01-01+00:01' is n
ot a valid value for 'dateTime'.
[Error] UserXsdError.xml:8:52: cvc-type.3.1.3: The value '1970-01-01+00:01' of e
lement 'fyi:BirthDate' is not valid.
read 17 bytes in 1381 ms: [Sex>\n</fyi:User>\n]
read -1 bytes in 1640 ms: no data read

Note that the XML schema is provided at a separated location: User.xsd.


socket\ - Apache Xerves Socket Sample

Read XML/DTD from Socket with socket\

Using Apache Xerces Socket Sample Programs

⇑⇑ FAQ for Apache Xerces XML Parser

2017-09-20, 44772🔥, 0💬