Skip to main content

Unmarshalling, XML data contains HTML tag- causes error

2 replies [Last post]
tafn430
Offline
Joined: 2005-05-04
Points: 0

I'm getting an error trying to unmarshall xml data that contains the html tag. This data is apparently supposed to be on multiple lines. The unmarshalling fails because it thinks that the is an element that is not defined in the schema. What's the way around this? Is there anyway I can make it ignore the tag.
For example:
This is line 1This is line two
Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09
Points: 0

Sounds like your XML document is wrong. After all, given the way you wrote your XML, the BR tag is indeed an element.

Shouldn't it be:

This is line 1<BR/>This is line two

or

This is line two]]>

malachid
Offline
Joined: 2004-05-16
Points: 0

Alternatively, you could specify that the HTML tags are allowed children in your XSD...

Deciding factors are:
1) don't use CDATA if the included HTML has CDATA elements itself
2) use CDATA if it needs to be human-readable/editable
3) use the XSD changes if you need to actually query against the included HTML

Personally, I usually go the CDATA approach so it is easy to find errors with Notepad. Check

http://forums.java.net/jive/thread.jspa?threadID=647&tstart=0

for details on my success with CDATA support.