Hello Ranchers. I have a small but annoying problem, and hope that you can help me out. I'm working on a programm which reads out xml messages and creates xml messages. I'm using the XOM package for that. Reading out the XML works fine, validating it is working fine as well. But on creation I got a problem. The root element of my created XML has to look like that:
The namespace is no problem, I add that in the following way:
But when I want to add the schema-declaration as an attribute:
I get the following error message:
nu.xom.NamespaceConflictException: Attribute prefixes must be declared. at nu.xom.Attribute._setNamespace(Attribute.java:516) at nu.xom.Attribute.<init>(Attribute.java:168) at nu.xom.Attribute.<init>(Attribute.java:70)
But I don't understand it.
I think I declared the prefix in the attribute ? (xsi:noNamespaceSchemaLocation)
Attaching a schema is no harder. Just place the necessary xmlns:xsi and xsi:noNamespaceSchemaLocation attributes on the root element.
Didn't I do just that? But it is not working... .
If anyone could shed a light on this I would be really grateful. I tried the IBM tutorials, the cafeconleche.org tutorials, and various others I found on google, but to no result yet . [ November 28, 2006: Message edited by: Jan Spengen ]
I also have no idea about XOM, and the link you posted goes to a site that isn't responding. The JAXP org.w3c.dom classes have both setAttribute and setAttributeNS methods, the latter to be used for namespaced attributes. Maybe XOM is the same except that it does better validation than DOM, which allows you to sneak attributes into the setAttribute method?
Joined: Nov 28, 2006
Originally posted by Paul Clapham: I also have no idea about XOM, and the link you posted goes to a site that isn't responding.
Hmm strange, both links are working for me.
Originally posted by Paul Clapham: The JAXP org.w3c.dom classes have both setAttribute and setAttributeNS methods, the latter to be used for namespaced attributes. Maybe XOM is the same except that it does better validation than DOM, which allows you to sneak attributes into the setAttribute method?
I think I don't understand your question.
Well thanks already for the reply. I guess I'll have to do some more digging for information. I thought a moment about switching to JDOM, but unfortunately that is not really an option.
Edit: Obviously the problem arises with the "xsi:" in
If I cut that out and do instead :
Creation runs through to the end without problem. But then I get the problem at validation time as my XML is then not valid against its schema.
Any Ideas why this is causing the error or how to walk around it? [ November 29, 2006: Message edited by: Jan Spengen ]