public void namespace(int namespaceCode, int properties) throws XPathException { if (!acceptAttributes) { throw NoOpenStartTagException.makeNoOpenStartTagException( Type.NAMESPACE, getNamePool().getPrefixFromNamespaceCode(namespaceCode), getPipelineConfiguration().getHostLanguage(), inDocument, false); } // avoid duplicates for (int n=0; n<countStack[depth - 1]; n++) { if (namespaces[namespacesSize - 1 - n] == namespaceCode) { return; } } addToStack(namespaceCode); countStack[depth - 1]++; }
public void namespace(int namespaceCode, int properties) throws XPathException { if (!acceptAttributes) { throw NoOpenStartTagException.makeNoOpenStartTagException( Type.NAMESPACE, getNamePool().getPrefixFromNamespaceCode(namespaceCode), getPipelineConfiguration().getHostLanguage(), inDocument, false); } // avoid duplicates for (int n=0; n<countStack[depth - 1]; n++) { if (namespaces[namespacesSize - 1 - n] == namespaceCode) { return; } } addToStack(namespaceCode); countStack[depth - 1]++; }
public void namespace(NamespaceBindingSet namespaceBindings, int properties) throws XPathException { for (NamespaceBinding ns : namespaceBindings) { if (!acceptAttributes) { throw NoOpenStartTagException.makeNoOpenStartTagException( Type.NAMESPACE, ns.getPrefix(), getPipelineConfiguration().getHostLanguage(), inDocument, ExplicitLocation.UNKNOWN_LOCATION); } // avoid duplicates for (int n = 0; n < countStack[depth - 1]; n++) { if (namespaces[namespacesSize - 1 - n].equals(namespaceBindings)) { return; } } addToStack(ns); countStack[depth - 1]++; } }
public void namespace(NamespaceBindingSet namespaceBindings, int properties) throws XPathException { for (NamespaceBinding ns : namespaceBindings) { if (!acceptAttributes) { throw NoOpenStartTagException.makeNoOpenStartTagException( Type.NAMESPACE, ns.getPrefix(), getPipelineConfiguration().getHostLanguage(), inDocument, ExplicitLocation.UNKNOWN_LOCATION); } // avoid duplicates for (int n = 0; n < countStack[depth - 1]; n++) { if (namespaces[namespacesSize - 1 - n].equals(namespaceBindings)) { return; } } addToStack(ns); countStack[depth - 1]++; } }
throw NoOpenStartTagException.makeNoOpenStartTagException( Type.ATTRIBUTE, attName.getDisplayName(), getPipelineConfiguration().getHostLanguage(), inDocument, ExplicitLocation.UNKNOWN_LOCATION);
throw NoOpenStartTagException.makeNoOpenStartTagException( Type.ATTRIBUTE, attName.getDisplayName(), getPipelineConfiguration().getHostLanguage(), inDocument, ExplicitLocation.UNKNOWN_LOCATION);
/** * Notify an attribute. Attributes are notified after the startElement event, and before any * children. Namespaces and attributes may be intermingled. * * @param nameCode The name of the attribute, as held in the name pool * @param typeCode The type of the attribute, as held in the name pool * @param properties Bit significant value. The following bits are defined: * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt> * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt> * @throws IllegalStateException: attempt to output an attribute when there is no open element * start tag */ public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties) throws XPathException { if (!acceptAttributes) { throw NoOpenStartTagException.makeNoOpenStartTagException( Type.ATTRIBUTE, getNamePool().getDisplayName(nameCode), getPipelineConfiguration().getHostLanguage(), inDocument, false); } // Perform namespace fixup for the attribute if (((properties & ReceiverOptions.NAMESPACE_OK) == 0) && NamePool.getPrefixIndex(nameCode) != 0) { // non-null prefix nameCode = checkProposedPrefix(nameCode, attCount++); } bufferedAttributes.addAttribute(nameCode, typeCode, value.toString(), locationId, properties); // Note: we're relying on the fact that AttributeCollection can hold two attributes of the same name // and maintain their order, because the check for duplicate attributes is not done until later in the // pipeline. We validate both the attributes (see Bugzilla #4600 which legitimizes this.) }
/** * Notify an attribute. Attributes are notified after the startElement event, and before any * children. Namespaces and attributes may be intermingled. * * @param nameCode The name of the attribute, as held in the name pool * @param typeCode The type of the attribute, as held in the name pool * @param properties Bit significant value. The following bits are defined: * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt> * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt> * @throws IllegalStateException: attempt to output an attribute when there is no open element * start tag */ public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties) throws XPathException { if (!acceptAttributes) { throw NoOpenStartTagException.makeNoOpenStartTagException( Type.ATTRIBUTE, getNamePool().getDisplayName(nameCode), getPipelineConfiguration().getHostLanguage(), inDocument, false); } // Perform namespace fixup for the attribute if (((properties & ReceiverOptions.NAMESPACE_OK) == 0) && NamePool.getPrefixIndex(nameCode) != 0) { // non-null prefix nameCode = checkProposedPrefix(nameCode, attCount++); } bufferedAttributes.addAttribute(nameCode, typeCode, value.toString(), locationId, properties); // Note: we're relying on the fact that AttributeCollection can hold two attributes of the same name // and maintain their order, because the check for duplicate attributes is not done until later in the // pipeline. We validate both the attributes (see Bugzilla #4600 which proposes to legitimize this.) }
/** * Get an element node representing the element whose start tag this is, as required * for implementing conditional type assignment * @return an element node. This contains all the required namespaces and attributes, and has no children; * it is untyped, as are the attributes. */ public NodeInfo getElementNode() throws XPathException { if (elementNode == null) { int len = bufferedAttributes.getLength(); TinyBuilder builder = new TinyBuilder(); builder.setSizeParameters(new int[]{2, len+2, namespacesSize+2, 16}); builder.setPipelineConfiguration(getPipelineConfiguration()); builder.open(); builder.startElement(elementNameCode, StandardNames.XS_UNTYPED_ATOMIC, 0, 0); for (int i=0; i<namespacesSize; i++) { builder.namespace(namespaces[i], 0); } for (int i=0; i<len; i++) { builder.attribute(bufferedAttributes.getNameCode(i), StandardNames.XS_UNTYPED_ATOMIC, bufferedAttributes.getValue(i), 0, 0); } builder.startContent(); builder.endElement(); elementNode = builder.getCurrentRoot(); } return elementNode; }