public String getValue(String uri, String localName) { int index = getIndex(uri, localName); if (index == -1) { return null; } else { return getValue(index); } }
public String getValue(String qName) { int index = getIndex(qName); if (index == -1) { return null; } else { return getValue(index); } }
public String getValue(String qName) { int index = getIndex(qName); if (index == -1) { return null; } else { return getValue(index); } }
public String getValue(String uri, String localName) { int index = getIndex(uri, localName); if (index == -1) { return null; } else { return getValue(index); } }
public String getValue(String uri, String localName) { int index = getIndex(uri, localName); if (index == -1) { return null; } else { return getValue(index); } }
public String getValue(String qName) { int index = getIndex(qName); if (index == -1) { return null; } else { return getValue(index); } }
/** * Only use with static argument. * * @see org.xml.sax.Attributes#getValue(java.lang.String) */ public String getValue(AttributeName name) { int index = getIndex(name); if (index == -1) { return null; } else { return getValue(index); } }
private boolean annotationXmlEncodingPermitsHtml(HtmlAttributes attributes) { String encoding = attributes.getValue(AttributeName.ENCODING); if (encoding == null) { return false; } return Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "application/xhtml+xml", encoding) || Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "text/html", encoding); }
private boolean annotationXmlEncodingPermitsHtml(HtmlAttributes attributes) { String encoding = attributes.getValue(AttributeName.ENCODING); if (encoding == null) { return false; } return Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "application/xhtml+xml", encoding) || Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "text/html", encoding); }
private boolean annotationXmlEncodingPermitsHtml(HtmlAttributes attributes) { String encoding = attributes.getValue(AttributeName.ENCODING); if (encoding == null) { return false; } return Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "application/xhtml+xml", encoding) || Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "text/html", encoding); }
/** * * @see nu.validator.htmlparser.impl.TreeBuilder#createHtmlElementSetAsRoot(nu.validator.htmlparser.impl.HtmlAttributes) */ @Override protected Element createHtmlElementSetAsRoot( HtmlAttributes attributes) throws SAXException { try { Element rv = document.createElementNS( "http://www.w3.org/1999/xhtml", "html"); for (int i = 0; i < attributes.getLength(); i++) { rv.setAttributeNS(attributes.getURI(i), attributes.getLocalName(i), attributes.getValue(i)); } document.appendChild(rv); return rv; } catch (DOMException e) { fatal(e); throw new RuntimeException("Unreachable"); } }
private void checkMetaCharset(HtmlAttributes attributes) throws SAXException { String charset = attributes.getValue(AttributeName.CHARSET); if (charset != null) { if (tokenizer.internalEncodingDeclaration(charset)) { requestSuspension(); return; } return; } if (!Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "content-type", attributes.getValue(AttributeName.HTTP_EQUIV))) { return; } String content = attributes.getValue(AttributeName.CONTENT); if (content != null) { String extract = TreeBuilder.extractCharsetFromContent(content); // remember not to return early without releasing the string if (extract != null) { if (tokenizer.internalEncodingDeclaration(extract)) { requestSuspension(); } } Portability.releaseString(extract); } }
private void checkMetaCharset(HtmlAttributes attributes) throws SAXException { String charset = attributes.getValue(AttributeName.CHARSET); if (charset != null) { if (tokenizer.internalEncodingDeclaration(charset)) { requestSuspension(); return; } return; } if (!Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString( "content-type", attributes.getValue(AttributeName.HTTP_EQUIV))) { return; } String content = attributes.getValue(AttributeName.CONTENT); if (content != null) { String extract = TreeBuilder.extractCharsetFromContent(content // CPPONLY: , this ); // remember not to return early without releasing the string if (extract != null) { if (tokenizer.internalEncodingDeclaration(extract)) { requestSuspension(); } } Portability.releaseString(extract); } }
public void merge(HtmlAttributes attributes) throws SAXException { int len = attributes.getLength(); for (int i = 0; i < len; i++) { AttributeName name = attributes.getAttributeName(i); if (!contains(name)) { addAttribute(name, attributes.getValue(i), XmlViolationPolicy.ALLOW); } } }
/** * * @see nu.validator.htmlparser.impl.TreeBuilder#addAttributesToElement(java.lang.Object, * nu.validator.htmlparser.impl.HtmlAttributes) */ @Override protected void addAttributesToElement(Element element, HtmlAttributes attributes) throws SAXException { try { for (int i = 0; i < attributes.getLength(); i++) { String localName = attributes.getLocalName(i); String uri = attributes.getURI(i); if (!element.hasAttributeNS(uri, localName)) { element.setAttributeNS(uri, localName, attributes.getValue(i)); } } } catch (DOMException e) { fatal(e); } }
/** * * @see nu.validator.htmlparser.impl.TreeBuilder#createElement(java.lang.String, * java.lang.String, nu.validator.htmlparser.impl.HtmlAttributes) */ @Override protected Element createElement(String ns, String name, HtmlAttributes attributes) throws SAXException { try { Element rv = document.createElementNS(ns, name); for (int i = 0; i < attributes.getLength(); i++) { rv.setAttributeNS(attributes.getURI(i), attributes.getLocalName(i), attributes.getValue(i)); if (attributes.getType(i) == "ID") { rv.setIdAttributeNS(null, attributes.getLocalName(i), true); } } return rv; } catch (DOMException e) { fatal(e); throw new RuntimeException("Unreachable"); } }
@Override protected Element createElement(String ns, String name, HtmlAttributes attributes) throws SAXException { try { Element rv = nodeFactory.makeElement(name, ns); for (int i = 0; i < attributes.getLength(); i++) { rv.addAttribute(nodeFactory.makeAttribute( attributes.getLocalName(i), attributes.getURI(i), attributes.getValue(i), attributes.getType(i) == "ID" ? Attribute.Type.ID : Attribute.Type.CDATA)); } return rv; } catch (XMLException e) { fatal(e); throw new RuntimeException("Unreachable"); } }
/** * @see nu.validator.htmlparser.impl.TreeBuilder#createElement(String, * java.lang.String, org.xml.sax.Attributes, java.lang.Object) */ @Override protected Element createElement(String ns, String name, HtmlAttributes attributes, Element form) throws SAXException { try { Element rv = nodeFactory.makeElement(name, ns, form); for (int i = 0; i < attributes.getLength(); i++) { rv.addAttribute(nodeFactory.makeAttribute( attributes.getLocalName(i), attributes.getURI(i), attributes.getValue(i), attributes.getType(i) == "ID" ? Attribute.Type.ID : Attribute.Type.CDATA)); } return rv; } catch (XMLException e) { fatal(e); throw new RuntimeException("Unreachable"); } }
@Override protected Element createHtmlElementSetAsRoot(HtmlAttributes attributes) throws SAXException { try { Element rv = nodeFactory.makeElement("html", "http://www.w3.org/1999/xhtml"); for (int i = 0; i < attributes.getLength(); i++) { rv.addAttribute(nodeFactory.makeAttribute( attributes.getLocalName(i), attributes.getURI(i), attributes.getValue(i), attributes.getType(i) == "ID" ? Attribute.Type.ID : Attribute.Type.CDATA)); } document.setRootElement(rv); return rv; } catch (XMLException e) { fatal(e); throw new RuntimeException("Unreachable"); } }
@Override protected void addAttributesToElement(Element element, HtmlAttributes attributes) throws SAXException { try { for (int i = 0; i < attributes.getLength(); i++) { String localName = attributes.getLocalName(i); String uri = attributes.getURI(i); if (element.getAttribute(localName, uri) == null) { element.addAttribute(nodeFactory.makeAttribute(localName, uri, attributes.getValue(i), attributes.getType(i) == "ID" ? Attribute.Type.ID : Attribute.Type.CDATA)); } } } catch (XMLException e) { fatal(e); } }