Element digestMethodElem = XMLHelper.constructElement(containingDocument, DigestMethod.DEFAULT_ELEMENT_NAME); XMLHelper.appendNamespaceDeclaration(digestMethodElem, XMLConstants.XMLSIG_NS, XMLConstants.XMLSIG_PREFIX); digestMethodElem.setAttributeNS(null, DigestMethod.ALGORITHM_ATTRIB_NAME,
Element digestMethodElem = XMLHelper.constructElement(containingDocument, DigestMethod.DEFAULT_ELEMENT_NAME); XMLHelper.appendNamespaceDeclaration(digestMethodElem, XMLConstants.XMLSIG_NS, XMLConstants.XMLSIG_PREFIX); digestMethodElem.setAttributeNS(null, DigestMethod.ALGORITHM_ATTRIB_NAME,
appendNamespaceDeclaration(domElement, namespaceURI, namespacePrefix); } else { appendNamespaceDeclaration(domElement, namespaceURI, namespacePrefix);
appendNamespaceDeclaration(domElement, namespaceURI, namespacePrefix); } else { appendNamespaceDeclaration(domElement, namespaceURI, namespacePrefix);
/** * Creates the xmlns attributes for any namespaces set on the given XMLObject. * * @param xmlObject the XMLObject * @param domElement the DOM element the namespaces will be added to */ protected void marshallNamespaces(XMLObject xmlObject, Element domElement) { log.trace("Marshalling namespace attributes for XMLObject {}", xmlObject.getElementQName()); Set<Namespace> namespaces = xmlObject.getNamespaces(); for (Namespace namespace : namespaces) { if (!namespace.alwaysDeclare()) { if (DatatypeHelper.safeEquals(namespace.getNamespacePrefix(), XMLConstants.XML_PREFIX) || DatatypeHelper.safeEquals(namespace.getNamespaceURI(), XMLConstants.XML_NS)) { // the "xml" namespace never needs to be declared continue; } String declared = XMLHelper.lookupNamespaceURI(domElement, namespace.getNamespacePrefix()); if (declared != null && namespace.getNamespaceURI().equals(declared)) { log.trace("Namespace {} has already been declared on an ancestor of {} no need to add it here", namespace, xmlObject.getElementQName()); continue; } } log.trace("Adding namespace declaration {} to {}", namespace, xmlObject.getElementQName()); String nsURI = DatatypeHelper.safeTrimOrNullString(namespace.getNamespaceURI()); String nsPrefix = DatatypeHelper.safeTrimOrNullString(namespace.getNamespacePrefix()); XMLHelper.appendNamespaceDeclaration(domElement, nsURI, nsPrefix); } }
/** * Creates the xmlns attributes for any namespaces set on the given XMLObject. * * @param xmlObject the XMLObject * @param domElement the DOM element the namespaces will be added to */ protected void marshallNamespaces(XMLObject xmlObject, Element domElement) { log.trace("Marshalling namespace attributes for XMLObject {}", xmlObject.getElementQName()); Set<Namespace> namespaces = xmlObject.getNamespaces(); for (Namespace namespace : namespaces) { if (!namespace.alwaysDeclare()) { if (DatatypeHelper.safeEquals(namespace.getNamespacePrefix(), XMLConstants.XML_PREFIX) || DatatypeHelper.safeEquals(namespace.getNamespaceURI(), XMLConstants.XML_NS)) { // the "xml" namespace never needs to be declared continue; } String declared = XMLHelper.lookupNamespaceURI(domElement, namespace.getNamespacePrefix()); if (declared != null && namespace.getNamespaceURI().equals(declared)) { log.trace("Namespace {} has already been declared on an ancestor of {} no need to add it here", namespace, xmlObject.getElementQName()); continue; } } log.trace("Adding namespace declaration {} to {}", namespace, xmlObject.getElementQName()); String nsURI = DatatypeHelper.safeTrimOrNullString(namespace.getNamespaceURI()); String nsPrefix = DatatypeHelper.safeTrimOrNullString(namespace.getNamespacePrefix()); XMLHelper.appendNamespaceDeclaration(domElement, nsURI, nsPrefix); } }