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); }
protected void writeNsDecls(int base) throws IOException { NamespaceContextImpl.Element ns = nsContext.getCurrent(); int size = nsContext.count(); for( int i=ns.getBase(); i<size; i++ ) writeNsDecl(i); }
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); } } }
@Override public void endStartTag() throws SAXException { super.endStartTag(); Object op = nsContext.getCurrent().getOuterPeer(); if(op!=null) assoc.addOuter( getBuilder().getCurrentElement(), op ); Object ip = nsContext.getCurrent().getInnerPeer(); if(ip!=null) assoc.addInner( getBuilder().getCurrentElement(), ip ); } }
public void beginStartTag(int prefix, String localName) throws IOException, XMLStreamException { out.writeStartElement( nsContext.getPrefix(prefix), localName, nsContext.getNamespaceURI(prefix)); 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.writeNamespace(nse.getPrefix(i),uri); } } }
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();
/** * Reset this object to write to the specified output. * * @param schemaLocation * if non-null, this value is printed on the root element as xsi:schemaLocation * @param noNsSchemaLocation * Similar to 'schemaLocation' but this one works for xsi:noNamespaceSchemaLocation */ public void startDocument(XmlOutput out,boolean fragment,String schemaLocation,String noNsSchemaLocation) throws IOException, SAXException, XMLStreamException { pushCoordinator(); nsContext.reset(); nse = nsContext.getCurrent(); if(attachmentMarshaller!=null && attachmentMarshaller.isXOPPackage()) out = new MTOMXmlOutput(out); this.out = out; objectsWithId.clear(); idReferencedObjects.clear(); textHasAlreadyPrinted = false; seenRoot = false; this.schemaLocation = schemaLocation; this.noNsSchemaLocation = noNsSchemaLocation; this.fragment = fragment; this.inlineBinaryFlag = false; this.expectedMimeType = null; cycleDetectionStack.reset(); out.startDocument(this,fragment,knownUri2prefixIndexMap,nsContext); }
/** * 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('\"'); }
@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(); }
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)); } } }
@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)); } }
public void text( Pcdata value, boolean needsSeparatingWhitespace ) throws IOException, SAXException, XMLStreamException { if(value instanceof Base64Data && !serializer.getInlineBinaryFlag()) { Base64Data b64d = (Base64Data) value; String cid; if(b64d.hasData()) cid = serializer.attachmentMarshaller.addMtomAttachment( b64d.get(),0,b64d.getDataLen(),b64d.getMimeType(),nsUri,localName); else cid = serializer.attachmentMarshaller.addMtomAttachment( b64d.getDataHandler(),nsUri,localName); if(cid!=null) { nsContext.getCurrent().push(); int prefix = nsContext.declareNsUri(WellKnownNamespace.XOP,"xop",false); beginStartTag(prefix,"Include"); attribute(-1,"href",cid); endStartTag(); endTag(prefix,"Include"); nsContext.getCurrent().pop(); return; } } next.text(value, needsSeparatingWhitespace); } }
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); }
protected void writeNsDecls(int base) throws IOException { NamespaceContextImpl.Element ns = nsContext.getCurrent(); int size = nsContext.count(); for( int i=ns.getBase(); i<size; i++ ) writeNsDecl(i); }
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.writeStartElement( nsContext.getPrefix(prefix), localName, nsContext.getNamespaceURI(prefix)); 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.writeNamespace(nse.getPrefix(i),uri); } } }
@Override public void endStartTag() throws SAXException { super.endStartTag(); Object op = nsContext.getCurrent().getOuterPeer(); if(op!=null) assoc.addOuter( getBuilder().getCurrentElement(), op ); Object ip = nsContext.getCurrent().getInnerPeer(); if(ip!=null) assoc.addInner( getBuilder().getCurrentElement(), ip ); } }
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)); } } }