/** * Note: constructing DTD events this way means that there will be no * internal presentation of actual DTD; no parsing is implied by * construction. */ @Override public DTD createDTD(String dtd) { return new DTDEventImpl(mLocation, dtd); }
public String getDocumentTypeDeclaration() { try { return doGetDocumentTypeDeclaration(); } catch (XMLStreamException sex) { // should never happen throw new RuntimeException("Internal error: "+sex); } }
public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (!(o instanceof DTD)) return false; DTD other = (DTD) o; /* Hmmh. Comparison for this event get very * tricky, very fast, if one tries to do it correctly * (partly due to Stax2 incompleteness, but not just * because of that)... let's actually try to minimize * work here */ return stringsWithNullsEqual(getDocumentTypeDeclaration(), other.getDocumentTypeDeclaration()); }
protected String doGetDocumentTypeDeclaration() throws XMLStreamException { if (mFullText == null) { int len = 60; if (mInternalSubset != null) { len += mInternalSubset.length() + 4; } StringWriter sw = new StringWriter(len); writeAsEncodedUnicode(sw); mFullText = sw.toString(); } return mFullText; } }
@Override public DTD2 createDTD(String rootName, String sysId, String pubId, String intSubset, Object processedDTD) { return new DTDEventImpl(mLocation, rootName, sysId, pubId, intSubset, processedDTD); }
public void writeUsing(XMLStreamWriter2 w) throws XMLStreamException { if (mRootName != null) { w.writeDTD(mRootName, mSystemId, mPublicId, mInternalSubset); return; } // Nah, just need to do a "dumb" write... w.writeDTD(doGetDocumentTypeDeclaration()); }
@Override public DTD2 createDTD(String rootName, String sysId, String pubId, String intSubset) { return new DTDEventImpl(mLocation, rootName, sysId, pubId, intSubset, null); }
protected DTD createDTD(XMLStreamReader r, Location loc) throws XMLStreamException { // Not sure if we really need this defensive coding but... if (r instanceof XMLStreamReader2) { XMLStreamReader2 sr2 = (XMLStreamReader2) r; DTDInfo dtd = sr2.getDTDInfo(); return new DTDEventImpl (loc, dtd.getDTDRootName(), dtd.getDTDSystemId(), dtd.getDTDPublicId(), dtd.getDTDInternalSubset(), dtd.getProcessedDTD()); } /* No way to get all information... the real big problem is * that of how to access root name: it's obligatory for * DOCTYPE construct. :-/ */ return new DTDEventImpl(loc, null, r.getText()); }