private void consumeEarlyTextIfNeeded() { if (!lostText_.isEmpty()) { if (!fSeenBodyElement) { forceStartBody(); } lostText_.refeed(this); } }
/** Empty element. */ public void emptyElement(final QName element, XMLAttributes attrs, Augmentations augs) throws XNIException { startElement(element, attrs, augs); // browser ignore the closing indication for non empty tags like <form .../> but not for unknown element final HTMLElements.Element elem = getElement(element); if (elem.isEmpty() || elem.code == HTMLElements.UNKNOWN) { endElement(element, augs); } } // emptyElement(QName,XMLAttributes,Augmentations)
/** * Generates a missing <body> (which creates missing <head> when needed) */ private void forceStartBody() { final QName body = createQName("body"); if (fReportErrors) { fErrorReporter.reportWarning("HTML2006", new Object[]{body.localpart}); } forceStartElement(body, null, synthesizedAugs()); }
for (int i=0; i<fragmentContextStack_.length; ++i) { final QName name = fragmentContextStack_[i]; final Element elt = HTMLElements.getElement(name.localpart); fElementStack.push(new Info(elt, name)); XercesBridge.getInstance().XMLDocumentHandler_startDocument(fDocumentHandler, locator, encoding, nscontext, augs);
/** * Forces an element start, taking care to set the information to allow startElement to "see" that's * the element has been forced. * @return <code>true</code> if creation could be done (TABLE's creation for instance can't be forced) */ private boolean forceStartElement(final QName elem, XMLAttributes attrs, final Augmentations augs) throws XNIException { forcedStartElement_ = true; startElement(elem, attrs, augs); return fElementStack.top > 0 && elem.equals(fElementStack.peek().qname); }
/** Returns an augmentations object with a synthesized item added. */ protected final Augmentations synthesizedAugs() { HTMLAugmentations augs = null; if (fAugmentations) { augs = fInfosetAugs; augs.removeAllItems(); augs.putItem(AUGMENTATIONS, SYNTHESIZED_ITEM); } return augs; } // synthesizedAugs():Augmentations
/** * Returns the depth of the open tag associated with the specified * element name or -1 if no matching element is found. * * @param element The element. */ protected final int getElementDepth(HTMLElements.Element element) { final boolean container = element.isContainer(); int depth = -1; for (int i = fElementStack.top - 1; i >=fragmentContextStackSize_; i--) { Info info = fElementStack.data[i]; if (info.element.code == element.code) { depth = fElementStack.top - i; break; } if (!container && (element.nestable && info.element.isBlock())) { break; } } return depth; } // getElementDepth(HTMLElements.Element)
/** * Returns the element information for the specified element name. * * @param ename The element name. */ public static final Element getElement(String ename) { return getElement(ename, NO_SUCH_ELEMENT); } // getElement(String):Element
/** Ignorable whitespace. */ public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException { characters(text, augs); } // ignorableWhitespace(XMLString,Augmentations)
/** Comment. */ public void comment(XMLString text, Augmentations augs) throws XNIException { fSeenAnything = true; consumeEarlyTextIfNeeded(); if (fDocumentHandler != null) { fDocumentHandler.comment(text, augs); } } // comment(XMLString,Augmentations)
/** * Consume elements that have been buffered, like </body></html> that are first consumed * at the end of document */ private void consumeBufferedEndElements() { final List toConsume = new ArrayList(endElementsBuffer_); endElementsBuffer_.clear(); for (int i=0; i<toConsume.size(); ++i) { final ElementEntry entry = (ElementEntry) toConsume.get(i); forcedEndElement_ = true; endElement(entry.name_, entry.augs_); } endElementsBuffer_.clear(); }
/** * Notifies the tagBalancingListener (if any) of an ignored start element */ private void notifyDiscardedStartElement(final QName elem, final XMLAttributes attrs, final Augmentations augs) { if (tagBalancingListener != null) tagBalancingListener.ignoredStartElement(elem, attrs, augs); }
/** * Notifies the tagBalancingListener (if any) of an ignored end element */ private void notifyDiscardedEndElement(final QName element, final Augmentations augs) { if (tagBalancingListener != null) tagBalancingListener.ignoredEndElement(element, augs); }
/** Start document. */ public void startDocument(XMLLocator locator, String encoding, Augmentations augs) throws XNIException { startDocument(locator, encoding, null, augs); } // startDocument(XMLLocator,String,Augmentations)
/** Sets a property. */ public void setProperty(String propertyId, Object value) throws XMLConfigurationException { if (propertyId.equals(NAMES_ELEMS)) { fNamesElems = getNamesValue(String.valueOf(value)); return; } if (propertyId.equals(NAMES_ATTRS)) { fNamesAttrs = getNamesValue(String.valueOf(value)); return; } } // setProperty(String,Object)
ElementEntry(final QName element, final Augmentations augs) { name_ = new QName(element); augs_ = (augs == null) ? null : new HTMLAugmentations(augs); } }
private QName createQName(String tagName) { tagName = modifyName(tagName, fNamesElems); return new QName(null, tagName, tagName, NamespaceBinder.XHTML_1_0_URI); }
/** Returns an HTML element. */ protected HTMLElements.Element getElement(final QName elementName) { String name = elementName.rawname; if (fNamespaces && NamespaceBinder.XHTML_1_0_URI.equals(elementName.uri)) { int index = name.indexOf(':'); if (index != -1) { name = name.substring(index+1); } } return HTMLElements.getElement(name); } // getElement(String):HTMLElements.Element
/** Processing instruction. */ public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException { fSeenAnything = true; consumeEarlyTextIfNeeded(); if (fDocumentHandler != null) { fDocumentHandler.processingInstruction(target, data, augs); } } // processingInstruction(String,XMLString,Augmentations)
/** Start CDATA section. */ public void startCDATA(Augmentations augs) throws XNIException { fSeenAnything = true; consumeEarlyTextIfNeeded(); // check for end of document if (fSeenRootElementEnd) { return; } // call handler if (fDocumentHandler != null) { fDocumentHandler.startCDATA(augs); } } // startCDATA(Augmentations)