List of usage examples for org.xml.sax.ext LexicalHandler startCDATA
public abstract void startCDATA() throws SAXException;
From source file:org.kalypso.gml.GMLSAXFactory.java
private void processValueType(final IValuePropertyType pt, final Object propertyValue, final QName prefixedQName) throws SAXException { final IMarshallingTypeHandler th = pt.getTypeHandler(); if (th instanceof ISimpleMarshallingTypeHandler<?>) { final String xmlString = printSimpleValue(pt, (ISimpleMarshallingTypeHandler<Object>) th, propertyValue);//from ww w . j a v a2s .co m if (xmlString != null) { // FIXME: this is the right place to write CDATA stuff, but of course now it is a wild hack // to look for a specific value. This must of course be decided in a more general way. // Maybe we register extensions for specific qnames? // TODO: also, it should be only done for String, i.e. in the XsdBaseTypeHandlerString final boolean doCData = prefixedQName.equals(new QName(NS.OM, "result")); final LexicalHandler lexicalHandler = doCData ? (LexicalHandler) m_reader.getProperty("http://xml.org/sax/properties/lexical-handler") : null; if (doCData) lexicalHandler.startCDATA(); m_reader.getContentHandler().characters(xmlString.toCharArray(), 0, xmlString.length()); if (doCData) lexicalHandler.endCDATA(); } return; } if (propertyValue != null) { try { th.marshal(propertyValue, m_reader, null, m_gmlVersion); } catch (final Exception e) { // Catch any exception here: we should always continue to write data in order to minimise data loss here // TODO: we need an error handler! Else the user does not get any information about errors // TODO Distinguish between normal exceptions and SaxParseException final ErrorHandler errorHandler = m_reader.getErrorHandler(); if (errorHandler == null) KalypsoDeegreePlugin.getDefault().getLog().log(StatusUtilities.statusFromThrowable(e)); else errorHandler .error(new SAXParseException("Failed to write property: " + pt.getQName(), null, e)); } } }