String nonNormalizedValue = attributes.getNonNormalizedValue(i); boolean specified = attributes.isSpecified(i); newattrs.addAttribute(aqname, type, value); newattrs.setNonNormalizedValue(i, nonNormalizedValue); newattrs.setSpecified(i, specified);
/** Element declaration. */ public void elementDecl(String ename, String model, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { fAttributes.removeAllAttributes(); fAttributes.addAttribute(A_ENAME, "NMTOKEN", ename); fAttributes.setSpecified(0, true); fAttributes.addAttribute(A_MODEL, "CDATA", model); fAttributes.setSpecified(1, true); fDocumentHandler.emptyElement(E_ELEMENT_DECL, fAttributes, augs); } } // elementDecl(String,String,Augmentations)
/** Text declaration. */ public void textDecl(String version, String encoding, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { fAttributes.removeAllAttributes(); if (version != null) { fAttributes.addAttribute(A_VERSION, "CDATA", version); fAttributes.setSpecified(0, true); } fAttributes.addAttribute(A_ENCODING, "CDATA", encoding); fAttributes.setSpecified(version!=null?1:0, true); fDocumentHandler.emptyElement(E_TEXT_DECL, fAttributes, augs); } } // textDecl(String,String,Augmentations)
@Override public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException { String location = String.valueOf(xmlLocator.getLineNumber()); attributes.addAttribute(new QName(MunitCore.LINE_NUMBER_ELEMENT_ATTRIBUTE, null, MunitCore.LINE_NUMBER_ELEMENT_ATTRIBUTE, NAMESPACE), "CDATA", location); super.startElement(element, attributes, augs); }
/** Internal entity declaration. */ public void internalEntityDecl(String name, XMLString value, XMLString nonvalue, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { fAttributes.removeAllAttributes(); fAttributes.addAttribute(A_NAME, "NMTOKEN", name); fAttributes.setSpecified(0, true); fAttributes.addAttribute(A_VALUE, "CDATA", value.toString()); fAttributes.setSpecified(1, true); fDocumentHandler.emptyElement(E_INTERNAL_ENTITY_DECL, fAttributes, augs); } } // internalEntityDecl(String,XMLString,XMLString,Augmentations)
/** Processing instruction. */ public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { fAttributes.removeAllAttributes(); fAttributes.addAttribute(A_TARGET, "NMTOKEN", target); fAttributes.setSpecified(0, true); fAttributes.addAttribute(A_DATA, "CDATA", data.toString()); fAttributes.setSpecified(1, true); fDocumentHandler.emptyElement(E_PROCESSING_INSTRUCTION, fAttributes, augs); } } // processingInstruction(String,XMLString,Augmentations)
/** * <p> * addAttribute * </p> * * @param arg0 * @param arg1 * @param arg2 * @return */ public int addAttribute( QName arg0, String arg1, String arg2 ) { int i = getIndex( arg0.rawname ); if ( i >= 0 ) attrs.removeAttributeAt( i ); return attrs.addAttribute( arg0, arg1, arg2 ); } /**
/** * <p> * addAttribute * </p> * * @param arg0 * @param arg1 * @param arg2 * @return */ public int addAttribute( QName arg0, String arg1, String arg2 ) { int i = getIndex( arg0.rawname ); if ( i >= 0 ) attrs.removeAttributeAt( i ); return attrs.addAttribute( arg0, arg1, arg2 ); } /**
/** Start attribute list. */ public void startAttlist(String ename, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { fAttributes.removeAllAttributes(); fAttributes.addAttribute(A_ENAME, "NMTOKEN", ename); fAttributes.setSpecified(0, true); fDocumentHandler.startElement(E_ATTLIST, fAttributes, augs); } } // startAttlist(String,Augmentations)
/** Separator in mixed or children content model. */ public void separator(short type, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { String groupType = type == SEPARATOR_CHOICE ? "|" : ","; fAttributes.removeAllAttributes(); fAttributes.addAttribute(A_TYPE, "CDATA", groupType); fAttributes.setSpecified(0, true); fDocumentHandler.emptyElement(E_SEPARATOR, fAttributes, augs); } } // separator(short,Augmentations)
/** Element reference in mixed or children content model. */ public void element(String name, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { fAttributes.removeAllAttributes(); fAttributes.addAttribute(A_NAME, "NMTOKEN", name); fAttributes.setSpecified(0, true); fDocumentHandler.emptyElement(E_ELEMENT, fAttributes, augs); } } // element(String,Augmentations)
/** External entity declaration. */ public void externalEntityDecl(String name, XMLResourceIdentifier id, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { fAttributes.removeAllAttributes(); fAttributes.addAttribute(A_NAME, "NMTOKEN", name); fAttributes.setSpecified(0, true); String publicId = id.getPublicId(); if (publicId != null) { fAttributes.addAttribute(A_PUBID, "CDATA", publicId); fAttributes.setSpecified(1, true); } String systemId = id.getLiteralSystemId(); fAttributes.addAttribute(A_SYSID, "CDATA", systemId); fAttributes.setSpecified(publicId!=null?2:1, true); fDocumentHandler.emptyElement(E_EXTERNAL_ENTITY_DECL, fAttributes, augs); } } // externalEntityDecl(String,XMLResourceIdentifier,Augmentations)
/** Start conditional section. */ public void startConditional(short type, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { String conditional = type == CONDITIONAL_IGNORE ? "IGNORE" : "INCLUDE"; fAttributes.removeAllAttributes(); fAttributes.addAttribute(A_TYPE, T_CONDITIONAL, conditional); fAttributes.setSpecified(0, true); fDocumentHandler.startElement(E_CONDITIONAL, fAttributes, augs); } } // startConditional(short,Augmentations)
/** Occurrence count in mixed or children content model. */ public void occurrence(short type, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { String occurs = type == OCCURS_ONE_OR_MORE ? "+" : type == OCCURS_ZERO_OR_MORE ? "*" : type == OCCURS_ZERO_OR_ONE ? "?" : null; fAttributes.removeAllAttributes(); fAttributes.addAttribute(A_TYPE, "CDATA", occurs); fAttributes.setSpecified(0, true); fDocumentHandler.emptyElement(E_OCCURRENCE, fAttributes, augs); } } // occurrence(short,Augmentations)
/** Start content model. */ public void startContentModel(String ename, Augmentations augs) throws XNIException { if (fDocumentHandler != null) { fAttributes.removeAllAttributes(); fAttributes.addAttribute(A_ENAME, "NMTOKEN", ename); fAttributes.setSpecified(0, true); fDocumentHandler.startElement(E_CONTENT_MODEL, fAttributes, augs); } } // startContentModel(String,Augmentations)
/** Synthesize namespace binding. */ protected void synthesizeBinding(XMLAttributes attrs, String ns) { String prefix = "xmlns"; String localpart = ns; String qname = prefix+':'+localpart; String uri = NamespaceBinder.NAMESPACES_URI; String atype = "CDATA"; String avalue = SYNTHESIZED_NAMESPACE_PREFX+fSynthesizedNamespaceCount++; // add attribute fQName.setValues(prefix, localpart, qname, uri); attrs.addAttribute(fQName, atype, avalue); // bind namespace XercesBridge.getInstance().NamespaceContext_declarePrefix(fNamespaceContext, ns, avalue); } // synthesizeBinding(XMLAttributes,String)
/** Synthesize namespace binding. */ protected void synthesizeBinding(XMLAttributes attrs, String ns) { String prefix = "xmlns"; String localpart = ns; String qname = prefix+':'+localpart; String uri = NamespaceBinder.NAMESPACES_URI; String atype = "CDATA"; String avalue = SYNTHESIZED_NAMESPACE_PREFX+fSynthesizedNamespaceCount++; // add attribute fQName.setValues(prefix, localpart, qname, uri); attrs.addAttribute(fQName, atype, avalue); // bind namespace XercesBridge.getInstance().NamespaceContext_declarePrefix(fNamespaceContext, ns, avalue); } // synthesizeBinding(XMLAttributes,String)
private void moveAttributeToStyle(XMLAttributes attributes, String attrName, String formatStr) { String attrValue = attributes.getValue(attrName); if (!StringUtils.isEmpty(attrValue)) { String newStyle = String.format(formatStr, attrValue); int styleIdx = attributes.getIndex("style"); if (styleIdx != -1) { String style = attributes.getValue(styleIdx); newStyle = newStyle + style; attributes.setValue(styleIdx, newStyle); } else { attributes.addAttribute(new QName(null, "style", "style", null), "CDATA", newStyle); } } }
/** * Synthesize namespace binding. */ protected void synthesizeBinding(XMLAttributes attrs, String ns) { String prefix = "xmlns"; String localpart = ns; String qname = prefix + ':' + localpart; String uri = NamespaceBinder.NAMESPACES_URI; String atype = "CDATA"; String avalue = SYNTHESIZED_NAMESPACE_PREFX + fSynthesizedNamespaceCount++; // add attribute fQName.setValues(prefix, localpart, qname, uri); attrs.addAttribute(fQName, atype, avalue); // bind namespace XercesBridge.getInstance().NamespaceContext_declarePrefix(fNamespaceContext, ns, avalue); } // synthesizeBinding(XMLAttributes,String)
/** * Synthesize namespace binding. */ protected void synthesizeBinding(XMLAttributes attrs, String ns) { String prefix = "xmlns"; String localpart = ns; String qname = prefix + ':' + localpart; String uri = NamespaceBinder.NAMESPACES_URI; String atype = "CDATA"; String avalue = SYNTHESIZED_NAMESPACE_PREFX + fSynthesizedNamespaceCount++; // add attribute fQName.setValues(prefix, localpart, qname, uri); attrs.addAttribute(fQName, atype, avalue); // bind namespace XercesBridge.getInstance().NamespaceContext_declarePrefix(fNamespaceContext, ns, avalue); } // synthesizeBinding(XMLAttributes,String)