[x3d-public] JSON to DOM inquiry (for XML schema)
John Carlson
yottzumm at gmail.com
Thu Dec 14 14:31:48 PST 2023
I got past this validation problem and I'm now validating JSON from
X3dToJson.xslt and DOM produced by X3JSONLD.java with XML schema, in
addition, I am serializing DOM to XML and validating that. With some help,
it might have taken a shorter amount of time. I hope I didn't crap out my
hands.
There are remaining tasks:
1) Make this approach long-running for batch requests. Batching is
working, but when I to get a large file, things seem to hang.
2) Getting x3d-tidy .x3dj output debugged. There appears to be some work
required here.
3) Validating that X3dToJson.xslt and X3DJSONLD.java can be
roundtripped back to XML. I could use help here with XML diff.
Here's the code:
x3dschema/Validate.java at main · coderextreme/x3dschema (github.com)
<https://github.com/coderextreme/x3dschema/blob/main/Validate.java>
<https://github.com/coderextreme/x3dschema/blob/main/Validate.java>x3dschema/X3DJSONLD.java
at main · coderextreme/x3dschema (github.com)
<https://github.com/coderextreme/x3dschema/blob/main/X3DJSONLD.java>
Enjoy!
John
On Thu, Dec 14, 2023 at 1:40 AM John Carlson <yottzumm at gmail.com> wrote:
>
>
> On Wed, Dec 13, 2023 at 9:11 PM John Carlson <yottzumm at gmail.com> wrote:
>
>> If someone could point me at a way to validate DOM documents in Java
>> with XML Schema, it would probably take me 1-4 days to start validating X3D
>> JSON with XML schema.
>>
>
> If someone could send me an X3D XML file that they know passes XML Schema
> and X3D validator, that would be appreciated. I am working on an X3D XML
> validator (with schema), and stumbling a bit. Working Java source code
> would be helpful too!
>
> Here's an example error passed to MyDefaultHandler. I'm using a
> DOMSource, like:
>
> DOMSource source = new
> DOMSource(document.getElementsByTagName("X3D").item(0));
> validator.validate(source);
>
> Passing just the document variable produces similar results.
>
> [apply] Processing C:\Users\john\x3dschema\examples\x3domflowers.x3d
> [apply] org.xml.sax.SAXParseException; cvc-elt.1.a: Cannot find the
> declaration of element 'X3D'.
> [apply] at
> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
> Source)
> [apply] at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
> Source)
> [apply] at
> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> [apply] at
> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> [apply] at
> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> [apply] at
> org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
> Source)
> [apply] at
> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
> [apply] at
> org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown
> Source)
> [apply] at
> org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown
> Source)
> [apply] at
> org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown
> Source)
> [apply] at
> org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
> [apply] at
> java.xml/javax.xml.validation.Validator.validate(Validator.java:124)
> [apply] at Validate.main(Unknown Source)
>
> Code is at link below. Basically, I don't see a file that doesn't throw
> this error, JSON or XML. Could it be how I'm constructing DOMSource?
>
> Feel free to comment out any JSON stuff.
>
> https://github.com/coderextreme/x3dschema/blob/main/Validate.java
>
> I just noticed that X3DJSAIL is using Xerces. I guess that's preferred.
>
> I'm taking a break for my hands. I'll probably continue trying stuff
> tomorrow.
>
> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20231214/86d2d7e2/attachment.html>
More information about the x3d-public
mailing list