return (("xmlns".equals(qName)) || qName.startsWith("xmlns:"));
}
public boolean processContainer(boolean element, int pos, int len) throws IOException, SAXException {
ByteArrayInput bis = new ByteArrayInput(data, pos, len);
XMLCompressedInput in = new XMLCompressedInput(bis, symbols);
String elemName = null;
String localName = null;
String nsURI = null;
String[] mappedPrefixes = null;
int nsMapCount = 0;
if ( element ) {
in.readSignature();
in.readContentSize();
short elemSymbol = in.readShort();
elemName = symbols.getName(elemSymbol);
localName = getLocalName(elemName);
nsURI = symbols.getNamespaceURI(elemSymbol);
int attrCount = in.readAttributeCount();
AttributesImpl attrs = new AttributesImpl();
for ( int i = 0 ; i < attrCount; i++ ) {
short symbol = in.readShort();
short strLen = in.readShort();
byte[] b = new byte[strLen];
in.read(b);
String attrName = symbols.getName(symbol);
String attrURI = symbols.getNamespaceURI(symbol);
String lclName = getLocalName(attrName);
String attrValue = new String(b, "UTF8");
// look for and buffer newly mapped namespace prefixes
if (isNSAttr(attrName)) {
// create the buffer if needed
if (mappedPrefixes == null) {
mappedPrefixes = new String[XMLNS_MAP_INCREMENT];
}
// check the buffer's capacity
if (nsMapCount >= mappedPrefixes.length) {
String[] newBuf = new String[mappedPrefixes.length + XMLNS_MAP_INCREMENT];
System.arraycopy(mappedPrefixes, 0, newBuf, 0, mappedPrefixes.length);
mappedPrefixes = newBuf;
}
/* The prefix is the attr "local name", unless this is the
* default namespace, in which case the prefix is the empty
* string
*/
String prefix = ("xmlns".equals(attrName) ? "" : lclName);
/*
* Prefix mappings MAY always be reported, regardless of
* feature settings.
*/
content.startPrefixMapping(prefix, attrValue);
mappedPrefixes[nsMapCount++] = prefix;
if (hasSaxNamespacesPrefixes) {
/*
* According to SAX, the local name should be EMPTY
*/
attrs.addAttribute("", "", attrName, "CDATA", attrValue);
}
} else {
/* Regular attribute */
attrs.addAttribute(attrURI != null ?
attrURI : "", lclName, attrName, "", attrValue);
}
}
if ( comp != null ) {
comp.symbolID(elemSymbol);
comp.dataLocation(pos, len);
}
content.startElement(nsURI !=null ? nsURI : "", localName, elemName, attrs);
}
else
in.readInt();
while ( !interrupt && bis.available() > 0 ) {
pos = bis.getPos();
/* TODO why is it used for? byte signature = */ in.readSignature();
len = in.readContentSize();
if ( len == 0 )
len = 1;
int type = in.getNodeType();
switch ( type ) {
case Node.ELEMENT_NODE:
processContainer(true, pos, len);
break;
case Node.TEXT_NODE:
case Node.PROCESSING_INSTRUCTION_NODE:
case Node.CDATA_SECTION_NODE:
case Node.COMMENT_NODE: {
ByteArrayInput tbis = new ByteArrayInput(data, pos, len);
XMLCompressedInput tin = new XMLCompressedInput(tbis, symbols);
tin.readSignature(); // Skip The Signature
if ( type == Node.TEXT_NODE )
tin.readContentSize();
else
tin.readInt();
byte[] buf = new byte[tbis.available()];
tin.read(buf);
String value = new String(buf, "UTF-8");
switch ( type ) {