/** * Creator for use when the XML violation policy requires an attribute name * to be changed. * * @param name * the name of the attribute to create */ static AttributeName create(@Local String name) { return new AttributeName(AttributeName.ALL_NO_NS, AttributeName.SAME_LOCAL(name), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG); }
boolean contains(AttributeName name) { for (int i = 0; i < length; i++) { if (name.equalsAnother(names[i])) { return true; } } for (int i = 0; i < xmlnsLength; i++) { if (name.equalsAnother(xmlnsNames[i])) { return true; } } return false; }
void processNonNcNames(TreeBuilder<?> treeBuilder, XmlViolationPolicy namePolicy) throws SAXException { for (int i = 0; i < length; i++) { AttributeName attName = names[i]; if (!attName.isNcName(mode)) { String name = attName.getLocal(mode); switch (namePolicy) { case ALTER_INFOSET: names[i] = AttributeName.create(NCName.escapeName(name)); // fall through case ALLOW: if (attName != AttributeName.XML_LANG) { treeBuilder.warn("Attribute \u201C" + name + "\u201D is not serializable as XML 1.0."); } break; case FATAL: treeBuilder.fatal("Attribute \u201C" + name + "\u201D is not serializable as XML 1.0."); break; } } } }
int length, Interner interner) { @Unsigned int hash = AttributeName.bufToHash(buf, length); int[] hashes; hashes = AttributeName.ATTRIBUTE_HASHES; int index = levelOrderBinarySearch(hashes, hash); if (index < 0) { return null; @Local String name = attributeName.getLocal(0); if (!Portability.localEqualsBuffer(name, buf, length)) { return null;
int hash = AttributeName.bufToHash(buf, length); int index = Arrays.binarySearch(AttributeName.ATTRIBUTE_HASHES, hash); if (index < 0) { return AttributeName.createAttributeName( Portability.newLocalNameFromBuffer(buf, offset, length, interner) } else { AttributeName attributeName = AttributeName.ATTRIBUTE_NAMES[index]; @Local String name = attributeName.getLocal(AttributeName.HTML); if (!Portability.localEqualsBuffer(name, buf, offset, length)) { return AttributeName.createAttributeName( Portability.newLocalNameFromBuffer(buf, offset, length, interner)
public int getIndex(String qName) { for (int i = 0; i < length; i++) { if (names[i].getQName(mode).equals(qName)) { return i; } } return -1; }
private void attributeNameComplete() throws SAXException { attributeName = AttributeName.nameByBuffer(strBuf, strBufLen, interner); if (attributeName == null) { // [NOCPP[ attributeName = AttributeName.createAttributeName( Portability.newLocalNameFromBuffer(strBuf, strBufLen, interner), namePolicy != XmlViolationPolicy.ALLOW); // ]NOCPP] // CPPONLY: nonInternedAttributeName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, strBufLen, interner)); // CPPONLY: attributeName = nonInternedAttributeName; } clearStrBufAfterUse(); if (attributes == null) { attributes = new HtmlAttributes(mappingLangToXmlLang); } /* * When the user agent leaves the attribute name state (and before * emitting the tag token, if appropriate), the complete attribute's * name must be compared to the other attributes on the same token; if * there is already an attribute on the token with the exact same name, * then this is a parse error and the new attribute must be dropped, * along with the value that gets associated with it (if any). */ if (attributes.contains(attributeName)) { errDuplicateAttribute(); attributeName = null; } }
public @Prefix String getPrefix(int index) { if (index < length && index >= 0) { return names[index].getPrefix(mode); } else { return null; } }
if (attributeName.isBoolean()) { if (html4ModeCompatibleWithXhtml1Schemata) { attributes.addAttribute(attributeName, attributeName.getLocal(AttributeName.HTML), xmlnsPolicy); } else { || AttributeName.HREF == attributeName) { warn("Attribute \u201C" + attributeName.getLocal(AttributeName.HTML) + "\u201D without an explicit value seen. The attribute may be dropped by IE7.");
/** * The startup-time constructor. * * @param uri * the namespace * @param local * the local name * @param prefix * the prefix * @param ncname * the ncnameness * @param xmlns * whether this is an xmlns attribute */ protected AttributeName(@NsUri @NoLength String[] uri, @Local @NoLength String[] local, @Prefix @NoLength String[] prefix // [NOCPP[ , int flags // ]NOCPP] ) { this.uri = uri; this.local = local; this.prefix = prefix; // [NOCPP[ this.qName = COMPUTE_QNAME(local, prefix); this.flags = flags; // ]NOCPP] }
void processNonNcNames(TreeBuilder<?> treeBuilder, XmlViolationPolicy namePolicy) throws SAXException { for (int i = 0; i < length; i++) { AttributeName attName = names[i]; if (!attName.isNcName(mode)) { String name = attName.getLocal(mode); switch (namePolicy) { case ALTER_INFOSET: names[i] = AttributeName.create(NCName.escapeName(name)); // fall through case ALLOW: if (attName != AttributeName.XML_LANG) { treeBuilder.warn("Attribute \u201C" + name + "\u201D is not serializable as XML 1.0."); } break; case FATAL: treeBuilder.fatal("Attribute \u201C" + name + "\u201D is not serializable as XML 1.0."); break; } } } }
int length, Interner interner) { @Unsigned int hash = AttributeName.bufToHash(buf, length); int[] hashes; hashes = AttributeName.ATTRIBUTE_HASHES; int index = levelOrderBinarySearch(hashes, hash); if (index < 0) { return null; @Local String name = attributeName.getLocal(0); if (!Portability.localEqualsBuffer(name, buf, length)) { return null;
public int getIndex(String qName) { for (int i = 0; i < length; i++) { if (names[i].getQName(mode).equals(qName)) { return i; } } return -1; }
private void attributeNameComplete() throws SAXException { attributeName = AttributeName.nameByBuffer(strBuf, strBufLen, interner); if (attributeName == null) { // [NOCPP[ attributeName = AttributeName.createAttributeName( Portability.newLocalNameFromBuffer(strBuf, strBufLen, interner), namePolicy != XmlViolationPolicy.ALLOW); // ]NOCPP] // CPPONLY: nonInternedAttributeName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, strBufLen, interner)); // CPPONLY: attributeName = nonInternedAttributeName; } clearStrBufAfterUse(); if (attributes == null) { attributes = new HtmlAttributes(mappingLangToXmlLang); } /* * When the user agent leaves the attribute name state (and before * emitting the tag token, if appropriate), the complete attribute's * name must be compared to the other attributes on the same token; if * there is already an attribute on the token with the exact same name, * then this is a parse error and the new attribute must be dropped, * along with the value that gets associated with it (if any). */ if (attributes.contains(attributeName)) { errDuplicateAttribute(); attributeName = null; } }
/** * Variant of <code>getPrefix(int index)</code> without bounds check. * @param index a valid attribute index * @return the namespace prefix at index */ public @Prefix String getPrefixNoBoundsCheck(int index) { return names[index].getPrefix(mode); }
/** * The startup-time constructor. * * @param uri * the namespace * @param local * the local name * @param prefix * the prefix * @param ncname * the ncnameness * @param xmlns * whether this is an xmlns attribute */ private AttributeName(@NsUri @NoLength String[] uri, @Local @NoLength String[] local, @Prefix @NoLength String[] prefix // [NOCPP[ , int flags // ]NOCPP] ) { this.uri = uri; this.local = local; this.prefix = prefix; // [NOCPP[ this.qName = COMPUTE_QNAME(local, prefix); this.flags = flags; // ]NOCPP] // CPPONLY: this.custom = false; }
void processNonNcNames(TreeBuilder<?> treeBuilder, XmlViolationPolicy namePolicy) throws SAXException { for (int i = 0; i < length; i++) { AttributeName attName = names[i]; if (!attName.isNcName(mode)) { String name = attName.getLocal(mode); switch (namePolicy) { case ALTER_INFOSET: names[i] = AttributeName.create(NCName.escapeName(name)); // fall through case ALLOW: if (attName != AttributeName.XML_LANG) { treeBuilder.warn("Attribute \u201C" + name + "\u201D is not serializable as XML 1.0."); } break; case FATAL: treeBuilder.fatal("Attribute \u201C" + name + "\u201D is not serializable as XML 1.0."); break; } } } }