public void endStartTag() throws SAXException { NamespaceContextImpl.Element ns = nsContext.getCurrent(); if(ns!=null) { int sz = ns.count(); for( int i=0; i<sz; i++ ) { String p = ns.getPrefix(i); String uri = ns.getNsUri(i); if(uri.length()==0 && ns.getBase()==1) continue; // no point in defining xmlns='' on the root out.startPrefixMapping(p,uri); } } out.startElement(elementNsUri,elementLocalName,elementQName,atts); }
current.setTagName(subst, current.elementLocalName, current.getOuterPeer()); current.setTagName(size, current.elementLocalName, current.getOuterPeer());
/** * Writes a single namespace declaration for the specified prefix. */ protected final void writeNsDecl(int prefixIndex) throws IOException { String p = nsContext.getPrefix(prefixIndex); if(p.length()==0) { if(nsContext.getCurrent().isRootElement() && nsContext.getNamespaceURI(prefixIndex).length()==0) return; // no point in declaring xmlns="" on the root element write(XMLNS_EQUALS); } else { Encoded e = prefixes[prefixIndex]; write(XMLNS_COLON); write(e.buf,0,e.len-1); // skip the trailing ':' write(EQUALS); } doText(nsContext.getNamespaceURI(prefixIndex),true); write('\"'); }
current.setTagName(subst, current.elementLocalName, current.getOuterPeer()); current.setTagName(size, current.elementLocalName, current.getOuterPeer());
current.setTagName(subst, current.elementLocalName, current.getOuterPeer()); current.setTagName(size, current.elementLocalName, current.getOuterPeer());
int count = nsContext.getCurrent().count();
private int pushNsDecls() { int total = nsContext.count(); NamespaceContextImpl.Element ns = nsContext.getCurrent(); if(total > prefixes.length) { // reallocate int m = Math.max(total,prefixes.length*2); Encoded[] buf = new Encoded[m]; System.arraycopy(prefixes,0,buf,0,prefixes.length); for( int i=prefixes.length; i<buf.length; i++ ) buf[i] = new Encoded(); prefixes = buf; } int base = Math.min(prefixCount,ns.getBase()); int size = nsContext.count(); for( int i=base; i<size; i++ ) { String p = nsContext.getPrefix(i); Encoded e = prefixes[i]; if(p.length()==0) { e.buf = EMPTY_BYTE_ARRAY; e.len = 0; } else { e.set(p); e.append(':'); } } prefixCount = size; return base; }
int count = nsContext.getCurrent().count();
private int pushNsDecls() { int total = nsContext.count(); NamespaceContextImpl.Element ns = nsContext.getCurrent(); if(total > prefixes.length) { // reallocate int m = Math.max(total,prefixes.length*2); Encoded[] buf = new Encoded[m]; System.arraycopy(prefixes,0,buf,0,prefixes.length); for( int i=prefixes.length; i<buf.length; i++ ) buf[i] = new Encoded(); prefixes = buf; } int base = Math.min(prefixCount,ns.getBase()); int size = nsContext.count(); for( int i=base; i<size; i++ ) { String p = nsContext.getPrefix(i); Encoded e = prefixes[i]; if(p.length()==0) { e.buf = EMPTY_BYTE_ARRAY; e.len = 0; } else { e.set(p); e.append(':'); } } prefixCount = size; return base; }
public void beginStartTagWithNamespaces(Name name) throws IOException { final NamespaceContextImpl.Element nse = nsContext.getCurrent(); fiout.writeLowLevelStartNamespaces(); for (int i = nse.count() - 1; i >= 0; i--) { final String uri = nse.getNsUri(i); if (uri.length() == 0 && nse.getBase() == 1) continue; // no point in definint xmlns='' on the root fiout.writeLowLevelNamespace(nse.getPrefix(i), uri); } fiout.writeLowLevelEndNamespaces(); final int qNameIndex = tables.elementIndexes[name.qNameIndex] - tables.indexOffset; final int prefixIndex = nsUriIndex2prefixIndex[name.nsUriIndex]; if (qNameIndex >= 0 && tables.elementIndexPrefixes[name.qNameIndex] == prefixIndex) { fiout.writeLowLevelStartElementIndexed(0, qNameIndex); } else { tables.elementIndexes[name.qNameIndex] = fiout.getNextElementIndex() + tables.indexOffset; tables.elementIndexPrefixes[name.qNameIndex] = prefixIndex; writeLiteral(EncodingConstants.ELEMENT_LITERAL_QNAME_FLAG, name, nsContext.getPrefix(prefixIndex), nsContext.getNamespaceURI(prefixIndex)); } }
@Override public void beginStartTag(int prefix, String localName) throws IOException { fiout.writeLowLevelTerminationAndMark(); int type = EncodingConstants.ELEMENT; if (nsContext.getCurrent().count() > 0) { final NamespaceContextImpl.Element nse = nsContext.getCurrent(); fiout.writeLowLevelStartNamespaces(); for (int i = nse.count() - 1; i >= 0; i--) { final String uri = nse.getNsUri(i); if (uri.length() == 0 && nse.getBase() == 1) continue; // no point in definint xmlns='' on the root fiout.writeLowLevelNamespace(nse.getPrefix(i), uri); } fiout.writeLowLevelEndNamespaces(); type= 0; } final boolean isIndexed = fiout.writeLowLevelStartElement( type, nsContext.getPrefix(prefix), localName, nsContext.getNamespaceURI(prefix)); if (!isIndexed) tables.incrementMaxIndexValue(); }
@Override public void beginStartTag(int prefix, String localName) throws IOException { fiout.writeLowLevelTerminationAndMark(); int type = EncodingConstants.ELEMENT; if (nsContext.getCurrent().count() > 0) { final NamespaceContextImpl.Element nse = nsContext.getCurrent(); fiout.writeLowLevelStartNamespaces(); for (int i = nse.count() - 1; i >= 0; i--) { final String uri = nse.getNsUri(i); if (uri.length() == 0 && nse.getBase() == 1) continue; // no point in definint xmlns='' on the root fiout.writeLowLevelNamespace(nse.getPrefix(i), uri); } fiout.writeLowLevelEndNamespaces(); type= 0; } final boolean isIndexed = fiout.writeLowLevelStartElement( type, nsContext.getPrefix(prefix), localName, nsContext.getNamespaceURI(prefix)); if (!isIndexed) tables.incrementMaxIndexValue(); }
@Override public void beginStartTag(Name name) throws IOException { fiout.writeLowLevelTerminationAndMark(); if (nsContext.getCurrent().count() == 0) { final int qNameIndex = tables.elementIndexes[name.qNameIndex] - tables.indexOffset; final int prefixIndex = nsUriIndex2prefixIndex[name.nsUriIndex]; if (qNameIndex >= 0 && tables.elementIndexPrefixes[name.qNameIndex] == prefixIndex) { fiout.writeLowLevelStartElementIndexed(EncodingConstants.ELEMENT, qNameIndex); } else { tables.elementIndexes[name.qNameIndex] = fiout.getNextElementIndex() + tables.indexOffset; tables.elementIndexPrefixes[name.qNameIndex] = prefixIndex; writeLiteral(EncodingConstants.ELEMENT | EncodingConstants.ELEMENT_LITERAL_QNAME_FLAG, name, nsContext.getPrefix(prefixIndex), nsContext.getNamespaceURI(prefixIndex)); } } else { beginStartTagWithNamespaces(name); } }
@Override public void beginStartTag(Name name) throws IOException { fiout.writeLowLevelTerminationAndMark(); if (nsContext.getCurrent().count() == 0) { final int qNameIndex = tables.elementIndexes[name.qNameIndex] - tables.indexOffset; final int prefixIndex = nsUriIndex2prefixIndex[name.nsUriIndex]; if (qNameIndex >= 0 && tables.elementIndexPrefixes[name.qNameIndex] == prefixIndex) { fiout.writeLowLevelStartElementIndexed(EncodingConstants.ELEMENT, qNameIndex); } else { tables.elementIndexes[name.qNameIndex] = fiout.getNextElementIndex() + tables.indexOffset; tables.elementIndexPrefixes[name.qNameIndex] = prefixIndex; writeLiteral(EncodingConstants.ELEMENT | EncodingConstants.ELEMENT_LITERAL_QNAME_FLAG, name, nsContext.getPrefix(prefixIndex), nsContext.getNamespaceURI(prefixIndex)); } } else { beginStartTagWithNamespaces(name); } }
public void beginStartTagWithNamespaces(Name name) throws IOException { final NamespaceContextImpl.Element nse = nsContext.getCurrent(); fiout.writeLowLevelStartNamespaces(); for (int i = nse.count() - 1; i >= 0; i--) { final String uri = nse.getNsUri(i); if (uri.length() == 0 && nse.getBase() == 1) continue; // no point in definint xmlns='' on the root fiout.writeLowLevelNamespace(nse.getPrefix(i), uri); } fiout.writeLowLevelEndNamespaces(); final int qNameIndex = tables.elementIndexes[name.qNameIndex] - tables.indexOffset; final int prefixIndex = nsUriIndex2prefixIndex[name.nsUriIndex]; if (qNameIndex >= 0 && tables.elementIndexPrefixes[name.qNameIndex] == prefixIndex) { fiout.writeLowLevelStartElementIndexed(0, qNameIndex); } else { tables.elementIndexes[name.qNameIndex] = fiout.getNextElementIndex() + tables.indexOffset; tables.elementIndexPrefixes[name.qNameIndex] = prefixIndex; writeLiteral(EncodingConstants.ELEMENT_LITERAL_QNAME_FLAG, name, nsContext.getPrefix(prefixIndex), nsContext.getNamespaceURI(prefixIndex)); } }
/** * Writes a single namespace declaration for the specified prefix. */ protected final void writeNsDecl(int prefixIndex) throws IOException { String p = nsContext.getPrefix(prefixIndex); if(p.length()==0) { if(nsContext.getCurrent().isRootElement() && nsContext.getNamespaceURI(prefixIndex).length()==0) return; // no point in declaring xmlns="" on the root element write(XMLNS_EQUALS); } else { Encoded e = prefixes[prefixIndex]; write(XMLNS_COLON); write(e.buf,0,e.len-1); // skip the trailing ':' write(EQUALS); } doText(nsContext.getNamespaceURI(prefixIndex),true); write('\"'); }
/** * Writes a single namespace declaration for the specified prefix. */ protected final void writeNsDecl(int prefixIndex) throws IOException { String p = nsContext.getPrefix(prefixIndex); if(p.length()==0) { if(nsContext.getCurrent().isRootElement() && nsContext.getNamespaceURI(prefixIndex).length()==0) return; // no point in declaring xmlns="" on the root element write(XMLNS_EQUALS); } else { Encoded e = prefixes[prefixIndex]; write(XMLNS_COLON); write(e.buf,0,e.len-1); // skip the trailing ':' write(EQUALS); } doText(nsContext.getNamespaceURI(prefixIndex),true); write('\"'); }
public void endTag(int prefix, String localName) throws SAXException { out.endElement( nsContext.getNamespaceURI(prefix), localName, getQName(prefix, localName) ); NamespaceContextImpl.Element ns = nsContext.getCurrent(); if(ns!=null) { int sz = ns.count(); for( int i=sz-1; i>=0; i-- ) { String p = ns.getPrefix(i); String uri = ns.getNsUri(i); if(uri.length()==0 && ns.getBase()==1) continue; // no point in definint xmlns='' on the root out.endPrefixMapping(p); } } }
public void beginStartTag(int prefix, String localName) throws IOException, XMLStreamException { out.add( ef.createStartElement( nsContext.getPrefix(prefix), nsContext.getNamespaceURI(prefix), localName)); NamespaceContextImpl.Element nse = nsContext.getCurrent(); if(nse.count()>0) { for( int i=nse.count()-1; i>=0; i-- ) { String uri = nse.getNsUri(i); if(uri.length()==0 && nse.getBase()==1) continue; // no point in definint xmlns='' on the root out.add(ef.createNamespace(nse.getPrefix(i),uri)); } } }
public void endTag(int prefix, String localName) throws SAXException { out.endElement( nsContext.getNamespaceURI(prefix), localName, getQName(prefix, localName) ); NamespaceContextImpl.Element ns = nsContext.getCurrent(); if(ns!=null) { int sz = ns.count(); for( int i=sz-1; i>=0; i-- ) { String p = ns.getPrefix(i); String uri = ns.getNsUri(i); if(uri.length()==0 && ns.getBase()==1) continue; // no point in definint xmlns='' on the root out.endPrefixMapping(p); } } }