protected Element createElementForFamilyLocal( String namespace, String localName ) { Document doc = getDocument(); Element result = null; if (namespace == null) { result = doc.createElementNS(null, localName); } else { String baseName = this.getBaseNamespace(); String prefix = ElementProxy.getDefaultPrefix(baseName); if (prefix == null || prefix.length() == 0) { result = doc.createElementNS(namespace, localName); result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", namespace); } else { result = doc.createElementNS(namespace, prefix + ":" + localName); result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix, namespace); } } return result; }
/** * Method addBigIntegerElement * * @param bi * @param localname */ public void addBigIntegerElement(BigInteger bi, String localname) { if (bi != null) { Element e = XMLUtils.createElementInSignatureSpace(getDocument(), localname); byte[] bytes = XMLUtils.getBytes(bi, bi.bitLength()); String encodedInt = XMLUtils.encodeToString(bytes); Document doc = e.getOwnerDocument(); Text text = doc.createTextNode(encodedInt); e.appendChild(text); appendSelf(e); addReturnToSelf(); } }
/** * Method addBase64Element * * @param bytes * @param localname */ public void addBase64Element(byte[] bytes, String localname) { if (bytes != null) { Element el = XMLUtils.createElementInSignatureSpace(getDocument(), localname); Text text = getDocument().createTextNode(XMLUtils.encodeToString(bytes)); el.appendChild(text); appendSelf(el); if (!XMLUtils.ignoreLineBreaks()) { appendSelf(createText("\n")); } } }
protected void setLocalIdAttribute(String attrName, String value) { if (value != null) { Attr attr = getDocument().createAttributeNS(null, attrName); attr.setValue(value); getElement().setAttributeNodeNS(attr); getElement().setIdAttributeNode(attr, true); } else { getElement().removeAttributeNS(null, attrName); } }
/** * Method addTextElement * * @param text * @param localname */ public void addTextElement(String text, String localname) { Element e = XMLUtils.createElementInSignatureSpace(getDocument(), localname); Text t = createText(text); appendOther(e, t); appendSelf(e); addReturnToSelf(); }