No, because it's not valid XML.  If you just serialize it
out regardless, you will have problems at the other end
because your XML parser will barf.

If I recall correctly, you can tell the serializer to
replace illegal characters with the Unicode replacement
char without complaining.  Would that be an option?

If you work with XML for a while, you start realizing that
it's not made for serializing arbitrary text.  If I were
to do this again, I would base64 encode the text and get
around these issues.  We could include a plain text copy
as an FYI for humans, but really use the base64 version
as the authoritative one.

--Thilo

On 13/07/11 16:21, Jörn Kottmann wrote:
> Hello,
> 
> a user tried to import a text file into the Cas Editor which
> contains a backspace character.
> 
> The Cas Editor treated it as any other unicode char and tried
> to write it into a CAS which is then serialized as XMI.
> But apparently the Xmi Serializer doesn't like that and
> throws an exception.
> 
> Shouldn't we support any valid unicode character?
> 
> Jörn
> 
> Stack trace:
> Caused by: org.xml.sax.SAXParseException: Trying to serialize non-XML 1.0
> character: , 0x8
>     at
> org.apache.uima.util.XMLSerializer$CharacterValidatingContentHandler.checkForInvalidXmlChars(XMLSerializer.java:254)
> 
>     at
> org.apache.uima.util.XMLSerializer$CharacterValidatingContentHandler.startElement(XMLSerializer.java:174)
> 
>     at
> org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.startElement(XmiCasSerializer.java:1003)
> 
>     at
> org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.encodeFS(XmiCasSerializer.java:755)
> 
>     at
> org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.encodeIndexed(XmiCasSerializer.java:700)
> 
>     at
> org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.serialize(XmiCasSerializer.java:268)
> 
>     at
> org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.access$700(XmiCasSerializer.java:108)
> 
>     at
> org.apache.uima.cas.impl.XmiCasSerializer.serialize(XmiCasSerializer.java:1567)
>     at
> org.apache.uima.cas.impl.XmiCasSerializer.serialize(XmiCasSerializer.java:1638)
>     at
> org.apache.uima.cas.impl.XmiCasSerializer.serialize(XmiCasSerializer.java:1585)
>     at
> org.apache.uima.caseditor.ide.wizards.DocumentImportStructureProvider.getDocument(DocumentImportStructureProvider.java:118)
> 
>     ... 9 more
> 

Reply via email to