NodeSeq to Document

20 views
Skip to first unread message

Eric Richardson

unread,
Jul 18, 2023, 9:28:44 PM7/18/23
to scalaxb
Hi,

I know this may be a basic question but I haven't figured out how to create a Document that can be parsed with regular Java XML tools. I would like to validate the document.

I create a NodeSeq like this.

val nodeSeq = scalaxb.toXML(msg, ...)
val bais = new ByteArrayInputStream(nodeSeq.text.getBytes)
...
validator.validate(new StreamSource(bais)

Content is not allowed in prolog.

I tried adding <?xml version="1.0" encoding="utf-8?> with no avail and saw a fix about BOM but not sure how I can take advantage of that. Scala XML examples I found online are pretty lacking.

Thanks,
Eric

Eric Richardson

unread,
Jul 18, 2023, 9:50:18 PM7/18/23
to scalaxb
I created a XML document from the text bytes and it is the very first character that is doesn't like. It looks like "<" but maybe not?

eugene yokota

unread,
Jul 18, 2023, 10:16:35 PM7/18/23
to sca...@googlegroups.com
scalaxb comes with SOAP integration, which sends SOAP envelope in HTTP, so you can look at that example

1. should be toString probably
2. the part that you omitted as ... is important too, like valid scope

thanks,
-eugene


--
You received this message because you are subscribed to the Google Groups "scalaxb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaxb+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaxb/4136e68f-53a6-49ff-a66d-666f1ee08cf6n%40googlegroups.com.

Eric Richardson

unread,
Jul 18, 2023, 11:27:16 PM7/18/23
to scalaxb
I do have the nodeName, namespace, and defaultScope, which includes all the potential namespaces.
The docs looked ok printed and also pretty printed.

Changing to the toString seems to have helped - at least I have different errors now.

Thanks,
Eric
Reply all
Reply to author
Forward
0 new messages