Exemplo n.º 1
0
 private void appendAttribute(StringBuilder sb, String name, String value) {
   sb.append(" ");
   sb.append(name);
   sb.append("=\"");
   sb.append(XMLUtil.escapeDoubleQuotedAttValue(value));
   sb.append("\"");
 }
Exemplo n.º 2
0
  public void characters(char[] ch, int start, int length) throws SAXException {
    try {
      if (inRDFContext) {
        // verify if we need to switch to XMLLiteral processing mode immediately.
        if (deferredElement != null && !parseLiteralMode) {
          Att parseType = deferredElement.atts.getAtt(RDF.NAMESPACE, "parseType");
          if (parseType != null && parseType.getValue().equals("Literal")) {
            setParseLiteralMode();
          }
        }

        if (parseLiteralMode) {
          if (deferredElement != null) {
            reportDeferredStartElement();
          }

          // Characters like '<', '>', and '&' must be escaped to
          // prevent breaking the XML text.
          String s = new String(ch, start, length);
          s = XMLUtil.escapeCharacterData(s);
          charBuf.append(s);
        } else {
          charBuf.append(ch, start, length);

          // if the element is not empty we need to process it as such. Otherwise,
          // we keep the start element deferred for now.
          if (deferredElement != null && charBuf.toString().trim().length() > 0) {
            reportDeferredStartElement();
          }
        }
      }
    } catch (RDFParseException e) {
      throw new SAXException(e);
    } catch (RDFHandlerException e) {
      throw new SAXException(e);
    }
  }