Refine search
public void checkNsDefaults(InputElementStack nsStack) throws XMLStreamException { // We only get called if mCurrElem != null, and has defaults HashMap m = mCurrElem.getNsDefaults(); if (m != null) { Iterator it = m.entrySet().iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); String prefix = (String) me.getKey(); if (!nsStack.isPrefixLocallyDeclared(prefix)) { DTDAttribute attr = (DTDAttribute) me.getValue(); String uri = attr.getDefaultValue(mContext, this); nsStack.addNsBinding(prefix, uri); } } } }
/** * Method called to connect the automatically handled DTD validator * (one detected from DOCTYPE, loaded and completely handled by * the stream reader without application calling validation methods). * Handled separately, since its behaviour is potentially different * from that of explicitly added validators. */ protected void setAutomaticDTDValidator(XMLValidator validator, NsDefaultProvider nsDefs) { mNsDefaultProvider = nsDefs; addValidator(validator); }
throws XMLStreamException super(input, cfg, cfg.getEntityResolver()); mConfigFlags = cfg.getConfigFlags(); mCfgCoalesceText = (mConfigFlags & CFG_COALESCE_TEXT) != 0; mCfgReportTextAsChars = (mConfigFlags & CFG_REPORT_CDATA) == 0; mXml11 = cfg.isXml11(); mAttrCollector = elemStack.getAttrCollector(); elemStack.connectReporter(this); mReturnNullForDefaultNamespace = mConfig.returnNullForDefaultNamespace();
public String getAttributeValue(String nsURI, String localName) { int ix = findAttributeIndex(nsURI, localName); return (ix < 0) ? null : getAttributeValue(ix); }
public void fireSaxStartElement(ContentHandler h, Attributes attrs) throws SAXException { if (h != null) { // First; any ns declarations? int nsCount = mElementStack.getCurrentNsCount(); for (int i = 0; i < nsCount; ++i) { String prefix = mElementStack.getLocalNsPrefix(i); String uri = mElementStack.getLocalNsURI(i); h.startPrefixMapping((prefix == null) ? "" : prefix, uri); } // Then start-elem event itself: String uri = mElementStack.getNsURI(); // Sax requires "" (not null) for ns uris... h.startElement((uri == null) ? "" : uri, mElementStack.getLocalName(), getPrefixedName(), attrs); } }
throws IOException, XMLStreamException super(input, cfg, cfg.getEntityResolver()); mConfigFlags = cfg.getConfigFlags(); mXml11 = cfg.isXml11(); mAttrCollector = elemStack.getAttrCollector(); elemStack.connectReporter(this);
throws IOException, XMLStreamException String ln = elemStack.getLocalName(); boolean nsAware = elemStack.isNamespaceAware(); String prefix = elemStack.getPrefix(); if (prefix != null && prefix.length() > 0) { // yup ln = prefix + ":" + ln; int nsCount = elemStack.getCurrentNsCount(); if (nsCount > 0) { for (int i = 0; i < nsCount; ++i) { String prefix = elemStack.getLocalNsPrefix(i); if (prefix == null || prefix.length() == 0) { // default NS decl prefix = XMLConstants.XML_NS_PREFIX; prefix = "xmlns:"+prefix; writeAttribute(prefix, elemStack.getLocalNsURI(i));
public String getAttributeType(int index) { if (mCurrToken != START_ELEMENT) { throw new IllegalStateException(ErrorConsts.ERR_STATE_NOT_STELEM); } // Attr. collector doesn't know it, elem stack does: return mElementStack.getAttributeType(index); }
public NamespaceContext getNonTransientNamespaceContext() { // null -> no Location info, not needed with basic API return mElementStack.createNonTransientNsContext(null); }
public String getAttributeNamespace(int index) { return getAttrCollector().getURI(index); }
public int getIndex(String qName) { if (mElemStack == null) { return -1; } int ix = mElemStack.findAttributeIndex(null, qName); // !!! In ns-as-attrs mode, should also match ns decls? return ix; }
public QName getName() { if (mCurrToken != START_ELEMENT && mCurrToken != END_ELEMENT) { throw new IllegalStateException(ErrorConsts.ERR_STATE_NOT_ELEM); } return mElementStack.getCurrentElementName(); }
public int getNamespaceCount() { if (mCurrToken != START_ELEMENT && mCurrToken != END_ELEMENT) { throw new IllegalStateException(ErrorConsts.ERR_STATE_NOT_ELEM); } return mElementStack.getCurrentNsCount(); }
int localCount = getCurrentNsCount() << 1; BaseNsContext nsCtxt = new CompactNsContext (loc, getDefaultNsURI(), mNamespaces.asArray(), totalNsSize, totalNsSize - localCount);
ies.addNsBinding(prefix, att.getNodeValue()); storedNamespaces.put(nodeName, att.getNodeValue());
throws IOException, XMLStreamException super(input, cfg, cfg.getEntityResolver()); mConfigFlags = cfg.getConfigFlags(); mXml11 = cfg.isXml11(); mAttrCollector = elemStack.getAttrCollector(); elemStack.connectReporter(this);
public void fireSaxEndElement(ContentHandler h) throws SAXException { if (h != null) { /* Order of events is reversed (wrt. start-element): first * the end tag event, then unbound prefixes */ String uri = mElementStack.getNsURI(); // Sax requires "" (not null) for ns uris... h.endElement((uri == null) ? "" : uri, mElementStack.getLocalName(), getPrefixedName()); // Any expiring ns declarations? int nsCount = mElementStack.getCurrentNsCount(); for (int i = 0; i < nsCount; ++i) { String prefix = mElementStack.getLocalNsPrefix(i); //String nsUri = mElementStack.getLocalNsURI(i); h.endPrefixMapping((prefix == null) ? "" : prefix); } } }
@Override public String getAttributeValue(String nsURI, String localName) { int ix = findAttributeIndex(nsURI, localName); return (ix < 0) ? null : getAttributeValue(ix); }
public String getType(int index) { if (index < mAttrCount) { if (index < 0) { return null; } /* Note: Woodstox will have separate type for enumerated values; * SAX considers these NMTOKENs, so may need to convert (but * note: some SAX impls also use "ENUMERATED") */ String type = mElemStack.getAttributeType(index); // Let's count on it being interned: if (type == "ENUMERATED") { type = "NMTOKEN"; } return type; } // But how about namespace declarations... let's just call them CDATA? index -= mAttrCount; if (index < mNsCount) { return "CDATA"; } return null; }
/** * Method called by {@link com.ctc.wstx.evt.DefaultEventAllocator} * to get double-indirection necessary for constructing start element * events. * * @return Null, if stream does not point to start element; whatever * callback returns otherwise. */ public Object withStartElement(ElemCallback cb, Location loc) { if (mCurrToken != START_ELEMENT) { return null; } return cb.withStartElement(loc, getName(), mElementStack.createNonTransientNsContext(loc), mAttrCollector.buildAttrOb(), mStEmptyElem); }