List of usage examples for org.dom4j DocumentType getInternalDeclarations
List<Decl> getInternalDeclarations();
From source file:com.cladonia.xml.ExchangerXMLWriter.java
License:Open Source License
protected void writeDocType(DocumentType docType) throws IOException { if (DEBUG)//from w ww . java 2 s .c o m System.out.println("ExchangerXMLWriter.writeDocType( " + docType + ")"); if (docType != null) { List list = docType.getInternalDeclarations(); if (list != null) { for (int i = 0; i < list.size(); i++) { Object internalDecl = list.get(i); if (internalDecl instanceof InternalEntityDecl) { InternalEntityDecl decl = (InternalEntityDecl) internalDecl; // System.out.println( "<!ENTITY "+decl.getName()+" \""+decl.getValue()+"\">"); String value = decl.getValue(); StringBuffer result = new StringBuffer("&"); int index = value.indexOf("&"); if (index != -1 && value.length() > 5) { if (index > 0) { result.append(value.substring(0, index + 1)); } result.append(value.substring(index + 5, value.length())); decl.setValue(result.toString()); } } else if (internalDecl instanceof ExternalEntityDecl) { ExternalEntityDecl decl = (ExternalEntityDecl) internalDecl; // System.out.println( "<!ENTITY "+decl.getName()+" \""+decl.getPublicID()+"\" \""+decl.getSystemID()+"\">"); // System.out.println( internalDecl.getClass()); // System.out.println( internalDecl.toString()); } } } docType.write(writer); writer.write(format.getLineSeparator()); writer.write(format.getLineSeparator()); } }
From source file:com.cladonia.xml.XMLFormatter.java
License:Mozilla Public License
protected void writeDocType(DocumentType docType) throws IOException { if (DEBUG)/*w ww.ja v a2 s .c o m*/ System.out.println("XMLFormatter.writeDocType( " + docType + ")"); if (docType != null) { List list = docType.getInternalDeclarations(); if (list != null) { for (int i = 0; i < list.size(); i++) { Object internalDecl = list.get(i); if (internalDecl instanceof InternalEntityDecl) { InternalEntityDecl decl = (InternalEntityDecl) internalDecl; String value = decl.getValue(); StringBuffer result = new StringBuffer("&"); int index = value.indexOf("&"); if (index != -1 && value.length() > 5) { if (index > 0) { result.append(value.substring(0, index + 1)); } result.append(value.substring(index + 5, value.length())); decl.setValue(result.toString()); } } } } docType.write(writer); writer.write(format.getLineSeparator()); writer.write(format.getLineSeparator()); } }