Example usage for org.w3c.dom Element setAttributeNS

List of usage examples for org.w3c.dom Element setAttributeNS

Introduction

In this page you can find the example usage for org.w3c.dom Element setAttributeNS.

Prototype

public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException;

Source Link

Document

Adds a new attribute.

Usage

From source file:be.fedict.eid.applet.service.signer.AbstractXmlSignatureService.java

public void postSign(byte[] signatureValue, List<X509Certificate> signingCertificateChain) {
    LOG.debug("postSign");

    /*//from ww  w.ja  v  a  2s . c  om
     * Retrieve the intermediate XML signature document from the temporary
     * data storage.
     */
    TemporaryDataStorage temporaryDataStorage = getTemporaryDataStorage();
    InputStream documentInputStream = temporaryDataStorage.getTempInputStream();
    String signatureId = (String) temporaryDataStorage.getAttribute(SIGNATURE_ID_ATTRIBUTE);
    LOG.debug("signature Id: " + signatureId);

    /*
     * Load the signature DOM document.
     */
    Document document;
    try {
        document = loadDocument(documentInputStream);
    } catch (Exception e) {
        throw new RuntimeException("DOM error: " + e.getMessage(), e);
    }

    /*
     * Locate the correct ds:Signature node.
     */
    Element nsElement = document.createElement("ns");
    nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:ds", Constants.SignatureSpecNS);
    Element signatureElement;
    try {
        signatureElement = (Element) XPathAPI.selectSingleNode(document,
                "//ds:Signature[@Id='" + signatureId + "']", nsElement);
    } catch (TransformerException e) {
        throw new RuntimeException("XPATH error: " + e.getMessage(), e);
    }
    if (null == signatureElement) {
        throw new RuntimeException("ds:Signature not found for @Id: " + signatureId);
    }

    /*
     * Insert signature value into the ds:SignatureValue element
     */
    NodeList signatureValueNodeList = signatureElement
            .getElementsByTagNameNS(javax.xml.crypto.dsig.XMLSignature.XMLNS, "SignatureValue");
    Element signatureValueElement = (Element) signatureValueNodeList.item(0);
    signatureValueElement.setTextContent(Base64.encode(signatureValue));

    //LOG.debug("signatureValue: "+Base64.encode(signatureValue));
    /*
     * Allow signature facets to inject their own stuff.
     */
    for (SignatureFacet signatureFacet : this.signatureFacets) {
        signatureFacet.postSign(signatureElement, signingCertificateChain);
    }

    OutputStream signedDocumentOutputStream = getSignedDocumentOutputStream();
    if (null == signedDocumentOutputStream) {
        throw new IllegalArgumentException("signed document output stream is null");
    }
    try {
        writeDocument(document, signedDocumentOutputStream);
    } catch (Exception e) {
        LOG.debug("error writing the signed XML document: " + e.getMessage(), e);
        throw new RuntimeException("error writing the signed XML document: " + e.getMessage(), e);
    }
}

From source file:net.sf.joost.emitter.DOMEmitter.java

/**
 * SAX2-Callback - Creates a DOM-element-node and memorizes it for the
 * {@link #endElement(String ,String ,String)} method by putting it onto the
 * top of this stack./*from  w  w w .  ja v a2s.  c om*/
 */
public void startElement(String uri, String local, String raw, Attributes attrs) throws SAXException {
    // create new element : iterate over all attribute-values
    Element elem = document.createElementNS(uri, raw);
    int nattrs = attrs.getLength();
    for (int i = 0; i < nattrs; i++) {
        String namespaceuri = attrs.getURI(i);
        String value = attrs.getValue(i);
        String qName = attrs.getQName(i);
        if ((namespaceuri == null) || (namespaceuri.equals(""))) {
            elem.setAttribute(qName, value);
        } else {
            elem.setAttributeNS(namespaceuri, qName, value);
        }
    }

    // append this new node onto current stack node
    insertNode(elem);
    // push this node into the global stack
    stack.push(elem);
}

From source file:edu.mayo.cts2.framework.core.xml.PatchedCastorMarshaller.java

protected Object unmarshalDomSource(DOMSource domSource) throws XmlMappingException {

    Node node = domSource.getNode();
    if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
        Element element = (Element) node;

        Node parent = node.getParentNode();
        while (parent != null) {
            NamedNodeMap atts = parent.getAttributes();
            if (atts != null) {
                for (int i = 0, j = atts.getLength(); i < j; i++) {

                    Attr att = (Attr) atts.item(i);
                    if (XMLNS_NS.equals(att.getNamespaceURI())) {
                        String name = att.getName();
                        String value = att.getValue();
                        if (!element.hasAttributeNS(XMLNS_NS, name)) {
                            element.setAttributeNS(XMLNS_NS, name, value);
                        }/*  w  w  w.  j a va2  s .  co m*/
                    }

                }
            }
            parent = parent.getParentNode();
        }
    }

    return super.unmarshalDomSource(domSource);
}

From source file:com.wfreitas.camelsoap.SoapClient.java

/**
 * Clone a collection node.// w  w w. j  av  a  2 s.c  o  m
 * <p/>
 * Note we have to frig with the OGNL expressions for collections/arrays because the
 * collection entry is represented by [0], [1] etc in the OGNL expression, not the actual
 * element name on the DOM e.g. collection node "order/items/item" (where "item" is the
 * actual collection entry) maps to the OGNL expression "order.items[0]" etc.
 *
 * @param element    The collection/array "entry" sub-branch.
 * @param cloneCount The number of times it needs to be cloned.
 * @param ognl       The OGNL expression for the collection/array. Not including the
 *                   indexing part.
 */
private void cloneCollectionTemplateElement(Element element, int cloneCount, String ognl) {
    if (element == null) {
        return;
    }

    Node insertPoint = element.getNextSibling();
    Node parent = element.getParentNode();

    element.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS,
            OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + OGNLUtils.OGNL_ATTRIB, ognl + "[0]");
    for (int i = 0; i < cloneCount; i++) {
        Element clone = (Element) element.cloneNode(true);

        clone.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + IS_CLONE_ATTRIB,
                "true");
        clone.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS,
                OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + OGNLUtils.OGNL_ATTRIB,
                ognl + "[" + Integer.toString(i + 1) + "]");
        if (insertPoint == null) {
            parent.appendChild(clone);
        } else {
            parent.insertBefore(clone, insertPoint);
        }
    }
}

From source file:ca.mcgill.music.ddmal.mei.MeiXmlWriter.java

/**
 * Turn an MeiElement into a DOM node./*from   w  ww  .  ja va 2  s.  c om*/
 */
Node meiElementToNode(MeiElement e) {
    MeiNamespace ns = e.getNamespace();
    Element element;
    // Return a comment early, since it has no children or attributes
    if (e.getName().equals("#comment")) {
        return document.createComment(e.getValue());
    } else {
        element = document.createElementNS(ns.getHref(), e.getName());
    }
    element.setAttribute("xml:id", e.getId());
    // Attributes with or without namespaces
    // TODO: Currently namespaces prefixes are ns0, etc.
    for (MeiAttribute attr : e.getAttributes()) {
        MeiNamespace attrNs = attr.getNamespace();
        if (attrNs != null) {
            element.setAttributeNS(attrNs.getHref(), attr.getName(), attr.getValue());
        } else {
            element.setAttribute(attr.getName(), attr.getValue());
        }
    }

    if (e.getValue() != null) {
        element.appendChild(document.createTextNode(e.getValue()));
    }
    // Add each child. Tail text is represented in XML as a text node
    // after the child, so add that if it exists.
    for (MeiElement ch : e.getChildren()) {
        element.appendChild(meiElementToNode(ch));
        if (ch.getTail() != null) {
            element.appendChild(document.createTextNode(ch.getTail()));
        }
    }
    return element;
}

From source file:com.evolveum.midpoint.prism.schema.SchemaToDomProcessor.java

/**
 * Set attribute in the DOM element to a string value.
 * @param element element element where to set attribute
 * @param attr attribute name (QName)//from  ww  w  .jav a  2 s.c  o m
 * @param attrValue attribute value (String)
 */
private void setAttribute(Element element, QName attr, String attrValue) {
    if (attributeQualified) {
        element.setAttributeNS(attr.getNamespaceURI(), attr.getLocalPart(), attrValue);
        addToImport(attr.getNamespaceURI());
    } else {
        element.setAttribute(attr.getLocalPart(), attrValue);
    }
}

From source file:be.fedict.eid.applet.service.signer.ooxml.OOXMLSignatureFacet.java

private void addSignatureTime(XMLSignatureFactory signatureFactory, Document document, String signatureId,
        List<XMLStructure> objectContent) {
    /*/*from   w  w w .ja v a 2s .  c om*/
     * SignatureTime
     */
    Element signatureTimeElement = document.createElementNS(OOXML_DIGSIG_NS, "mdssi:SignatureTime");
    signatureTimeElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:mdssi", OOXML_DIGSIG_NS);
    Element formatElement = document.createElementNS(OOXML_DIGSIG_NS, "mdssi:Format");
    formatElement.setTextContent("YYYY-MM-DDThh:mm:ssTZD");
    signatureTimeElement.appendChild(formatElement);
    Element valueElement = document.createElementNS(OOXML_DIGSIG_NS, "mdssi:Value");
    Date now = this.clock.getTime();
    DateTime dateTime = new DateTime(now.getTime(), DateTimeZone.UTC);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis();
    String nowStr = fmt.print(dateTime);
    LOG.debug("now: " + nowStr);
    valueElement.setTextContent(nowStr);
    signatureTimeElement.appendChild(valueElement);

    List<XMLStructure> signatureTimeContent = new LinkedList<XMLStructure>();
    signatureTimeContent.add(new DOMStructure(signatureTimeElement));
    SignatureProperty signatureTimeSignatureProperty = signatureFactory
            .newSignatureProperty(signatureTimeContent, "#" + signatureId, "idSignatureTime");
    List<SignatureProperty> signaturePropertyContent = new LinkedList<SignatureProperty>();
    signaturePropertyContent.add(signatureTimeSignatureProperty);
    SignatureProperties signatureProperties = signatureFactory.newSignatureProperties(signaturePropertyContent,
            "id-signature-time-" + UUID.randomUUID().toString());
    objectContent.add(signatureProperties);
}

From source file:be.fedict.eid.applet.service.signer.ooxml.OOXMLSignatureVerifier.java

private Map<String, String> getResources(byte[] document)
        throws IOException, ParserConfigurationException, SAXException, TransformerException {

    Map<String, String> signatureResources = new HashMap<String, String>();

    ByteArrayInputStream bais = new ByteArrayInputStream(document);
    ZipInputStream zipInputStream = new ZipInputStream(bais);
    ZipEntry zipEntry;/*from w ww  . j a  va 2  s .  c om*/
    while (null != (zipEntry = zipInputStream.getNextEntry())) {
        if (!"[Content_Types].xml".equals(zipEntry.getName())) {
            continue;
        }
        Document contentTypesDocument = OOXMLSignatureFacet.loadDocument(zipInputStream);
        Element nsElement = contentTypesDocument.createElement("ns");
        nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:tns",
                "http://schemas.openxmlformats.org/package/2006/content-types");

        for (String contentType : OOXMLSignatureFacet.contentTypes) {
            NodeList nodeList = XPathAPI.selectNodeList(contentTypesDocument,
                    "/tns:Types/tns:Override[@ContentType='" + contentType + "']/@PartName", nsElement);
            for (int nodeIdx = 0; nodeIdx < nodeList.getLength(); nodeIdx++) {
                String partName = nodeList.item(nodeIdx).getTextContent();
                LOG.debug("part name: " + partName);
                partName = partName.substring(1); // remove '/'
                signatureResources.put(partName, contentType);
            }
        }
        break;
    }
    return signatureResources;
}

From source file:be.docarch.odt2braille.PEF.java

/**
 * Converts the flat .odt filt to a .pef file according to the braille settings.
 *
 * This function/*ww  w .j a  v  a 2 s  .  com*/
 * <ul>
 * <li>uses {@link ODT} to convert the .odt file to multiple DAISY-like xml files,</li>
 * <li>uses {@link LiblouisXML} to translate these files into braille, and</li>
 * <li>recombines these braille files into one single .pef file.</li>
 * </ul>
 *
 * First, the document <i>body</i> is processed and split in volumes, then the <i>page ranges</i> are calculated
 * and finally the <i>preliminary pages</i> of each volume are processed and inserted at the right places.
 * The checker checks the DAISY-like files and the volume lengths.
 *
 */

public boolean makePEF() throws IOException, ParserConfigurationException, TransformerException,
        InterruptedException, SAXException, ConversionException, LiblouisXMLException, Exception {

    logger.entering("PEF", "makePEF");

    Configuration settings = odt.getConfiguration();

    Element[] volumeElements;
    Element sectionElement;
    File bodyFile = null;
    File brailleFile = null;
    File preliminaryFile = null;

    List<Volume> volumes = manager.getVolumes();

    String volumeInfo = capitalizeFirstLetter(
            ResourceBundle.getBundle(L10N, settings.mainLocale).getString("in")) + " " + volumes.size() + " "
            + ResourceBundle.getBundle(L10N, settings.mainLocale)
                    .getString((volumes.size() > 1) ? "volumes" : "volume")
            + "\n@title\n@pages";

    volumeElements = new Element[volumes.size()];

    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    docFactory.setValidating(false);
    docFactory.setNamespaceAware(true);
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
    DOMImplementation impl = docBuilder.getDOMImplementation();

    Document document = impl.createDocument(pefNS, "pef", null);
    Element root = document.getDocumentElement();
    root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", pefNS);
    root.setAttributeNS(null, "version", "2008-1");

    Element headElement = document.createElementNS(pefNS, "head");
    Element metaElement = document.createElementNS(pefNS, "meta");
    metaElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:dc", "http://purl.org/dc/elements/1.1/");
    Element dcElement = document.createElementNS("http://purl.org/dc/elements/1.1/", "dc:identifier");
    dcElement.appendChild(document.createTextNode(Integer.toHexString((int) (Math.random() * 1000000)) + " "
            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format((new Date()))));
    metaElement.appendChild(dcElement);
    dcElement = document.createElementNS("http://purl.org/dc/elements/1.1/", "dc:format");
    dcElement.appendChild(document.createTextNode("application/x-pef+xml"));
    metaElement.appendChild(dcElement);
    headElement.appendChild(metaElement);

    root.appendChild(headElement);

    int columns = pefSettings.getColumns();
    int rows = pefSettings.getRows();
    boolean duplex = pefSettings.getDuplex();
    int rowgap = pefSettings.getEightDots() ? 1 : 0;
    int beginPage = settings.getBeginningBraillePageNumber();

    if (statusIndicator != null) {
        statusIndicator.start();
        statusIndicator.setSteps(volumes.size());
        statusIndicator.setStatus(ResourceBundle.getBundle(L10N, statusIndicator.getPreferredLocale())
                .getString("statusIndicatorStep"));
    }

    for (int volumeCount = 0; volumeCount < volumes.size(); volumeCount++) {

        volumeElements[volumeCount] = document.createElementNS(pefNS, "volume");
        volumeElements[volumeCount].setAttributeNS(null, "cols", String.valueOf(columns));
        volumeElements[volumeCount].setAttributeNS(null, "rows",
                String.valueOf(rows + (int) Math.ceil(((rows - 1) * rowgap) / 4d)));
        volumeElements[volumeCount].setAttributeNS(null, "rowgap", String.valueOf(rowgap));
        volumeElements[volumeCount].setAttributeNS(null, "duplex", duplex ? "true" : "false");

        Volume volume = volumes.get(volumeCount);

        // Body section

        logger.info("Processing volume " + (volumeCount + 1) + " : " + volume.getTitle());

        if (!(volume instanceof PreliminaryVolume)) {

            bodyFile = File.createTempFile(TMP_NAME, ".daisy.body." + (volumeCount + 1) + ".xml", TMP_DIR);
            bodyFile.deleteOnExit();
            brailleFile = File.createTempFile(TMP_NAME, ".txt", TMP_DIR);
            brailleFile.deleteOnExit();

            odt.getBodyMatter(bodyFile, volume);
            liblouisXML.configure(bodyFile, brailleFile, false, beginPage);
            liblouisXML.run();

            // Read pages
            sectionElement = document.createElementNS(pefNS, "section");
            int pageCount = addPagesToSection(document, sectionElement, brailleFile, rows, columns, -1);
            volumeElements[volumeCount].appendChild(sectionElement);

            // Checker
            if (checker != null) {
                checker.checkDaisyFile(bodyFile);
            }

            // Braille page range
            volume.setBraillePagesStart(beginPage);
            volume.setNumberOfBraillePages(pageCount);
            beginPage += pageCount;

            // Print page range
            if (volume.getFrontMatter() && settings.getVolumeInfoEnabled()) {
                extractPrintPageRange(bodyFile, volume, settings);
            }
        }

        // Special symbols list
        if (volume.getSpecialSymbolListEnabled()) {
            extractSpecialSymbols(bodyFile, volume, volumeCount, settings);
        }

        // Preliminary section

        if (volume.getFrontMatter() || volume.getTableOfContent() || volume.getTranscribersNotesPageEnabled()
                || volume.getSpecialSymbolListEnabled()) {

            preliminaryFile = File.createTempFile(TMP_NAME, ".daisy.front." + (volumeCount + 1) + ".xml",
                    TMP_DIR);
            preliminaryFile.deleteOnExit();
            brailleFile = File.createTempFile(TMP_NAME, ".txt", TMP_DIR);
            brailleFile.deleteOnExit();

            odt.getFrontMatter(preliminaryFile, volume, volumeInfo);
            liblouisXML.configure(preliminaryFile, brailleFile, true,
                    volume.getTableOfContent() ? volume.getFirstBraillePage() : 1);
            liblouisXML.run();

            // Page range
            int pageCount = countPages(brailleFile, volume);
            volume.setNumberOfPreliminaryPages(pageCount);

            // Translate again with updated volume info and without volume separator marks
            brailleFile = File.createTempFile(TMP_NAME, ".txt", TMP_DIR);
            brailleFile.deleteOnExit();
            odt.getFrontMatter(preliminaryFile, volume, volumeInfo);
            liblouisXML.configure(preliminaryFile, brailleFile, false,
                    volume.getTableOfContent() ? volume.getFirstBraillePage() : 1);
            liblouisXML.run();

            // Read pages
            sectionElement = document.createElementNS(pefNS, "section");
            addPagesToSection(document, sectionElement, brailleFile, rows, columns, pageCount);
            volumeElements[volumeCount].insertBefore(sectionElement,
                    volumeElements[volumeCount].getFirstChild());

            // Checker
            if (checker != null) {
                checker.checkDaisyFile(preliminaryFile);
            }
        }

        if (statusIndicator != null) {
            statusIndicator.increment();
        }
    }

    if (checker != null) {
        checker.checkVolumes(volumes);
    }

    Element bodyElement = document.createElementNS(pefNS, "body");

    for (int volumeCount = 0; volumeCount < volumes.size(); volumeCount++) {
        bodyElement.appendChild(volumeElements[volumeCount]);
    }

    root.appendChild(bodyElement);

    document.insertBefore((ProcessingInstruction) document.createProcessingInstruction("xml-stylesheet",
            "type='text/css' href='pef.css'"), document.getFirstChild());

    OdtUtils.saveDOM(document, pefFile);

    logger.exiting("PEF", "makePEF");

    if (!validatePEF(pefFile)) {
        return false;
    }

    return true;
}

From source file:be.fedict.eid.applet.service.signer.ooxml.OOXMLSignatureFacet.java

private void addSignatureInfo(XMLSignatureFactory signatureFactory, Document document, String signatureId,
        List<Reference> references, List<XMLObject> objects)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    List<XMLStructure> objectContent = new LinkedList<XMLStructure>();

    Element signatureInfoElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureInfoV1");
    signatureInfoElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", OFFICE_DIGSIG_NS);

    Element setupIDElement = document.createElementNS(OFFICE_DIGSIG_NS, "SetupID");

    signatureInfoElement.appendChild(setupIDElement);

    Element signatureTextElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureText");

    signatureInfoElement.appendChild(signatureTextElement);

    Element signatureImageElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureImage");

    signatureInfoElement.appendChild(signatureImageElement);

    Element signatureCommentsElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureComments");

    signatureInfoElement.appendChild(signatureCommentsElement);

    Element windowsVersionElement = document.createElementNS(OFFICE_DIGSIG_NS, "WindowsVersion");
    windowsVersionElement.setTextContent("6.1");
    signatureInfoElement.appendChild(windowsVersionElement);

    Element officeVersionElement = document.createElementNS(OFFICE_DIGSIG_NS, "OfficeVersion");
    officeVersionElement.setTextContent("15.0");
    signatureInfoElement.appendChild(officeVersionElement);

    Element applicationVersionElement = document.createElementNS(OFFICE_DIGSIG_NS, "ApplicationVersion");
    applicationVersionElement.setTextContent("15.0");
    signatureInfoElement.appendChild(applicationVersionElement);

    Element monitorsElement = document.createElementNS(OFFICE_DIGSIG_NS, "Monitors");
    monitorsElement.setTextContent("1");
    signatureInfoElement.appendChild(monitorsElement);

    Element horizontalResolutionElement = document.createElementNS(OFFICE_DIGSIG_NS, "HorizontalResolution");
    horizontalResolutionElement.setTextContent("1366");
    signatureInfoElement.appendChild(horizontalResolutionElement);

    Element verticalResolutionElement = document.createElementNS(OFFICE_DIGSIG_NS, "VerticalResolution");
    verticalResolutionElement.setTextContent("768");
    signatureInfoElement.appendChild(verticalResolutionElement);

    Element colorDepthElement = document.createElementNS(OFFICE_DIGSIG_NS, "ColorDepth");
    colorDepthElement.setTextContent("32");
    signatureInfoElement.appendChild(colorDepthElement);

    Element signatureProviderIdElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureProviderId");
    signatureProviderIdElement.setTextContent("{00000000-0000-0000-0000-000000000000}");
    signatureInfoElement.appendChild(signatureProviderIdElement);

    Element signatureProviderUrlElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureProviderUrl");
    signatureInfoElement.appendChild(signatureProviderUrlElement);

    Element signatureProviderDetailsElement = document.createElementNS(OFFICE_DIGSIG_NS,
            "SignatureProviderDetails");
    signatureProviderDetailsElement.setTextContent("9");
    signatureInfoElement.appendChild(signatureProviderDetailsElement);

    Element manifestHashAlgorithmElement = document.createElementNS(OFFICE_DIGSIG_NS, "ManifestHashAlgorithm");
    manifestHashAlgorithmElement.setTextContent("http://www.w3.org/2000/09/xmldsig#sha1");
    signatureInfoElement.appendChild(manifestHashAlgorithmElement);

    Element signatureTypeElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureType");
    signatureTypeElement.setTextContent("1");
    signatureInfoElement.appendChild(signatureTypeElement);

    List<XMLStructure> signatureInfoContent = new LinkedList<XMLStructure>();
    signatureInfoContent.add(new DOMStructure(signatureInfoElement));
    SignatureProperty signatureInfoSignatureProperty = signatureFactory
            .newSignatureProperty(signatureInfoContent, "#" + signatureId, "idOfficeV1Details");

    List<SignatureProperty> signaturePropertyContent = new LinkedList<SignatureProperty>();
    signaturePropertyContent.add(signatureInfoSignatureProperty);
    SignatureProperties signatureProperties = signatureFactory.newSignatureProperties(signaturePropertyContent,
            null);//w  w  w  .  j  ava2  s  .c  o m
    objectContent.add(signatureProperties);

    String objectId = "idOfficeObject";
    objects.add(signatureFactory.newXMLObject(objectContent, objectId, null, null));

    DigestMethod digestMethod = signatureFactory.newDigestMethod(this.digestAlgo.getXmlAlgoId(), null);
    Reference reference = signatureFactory.newReference("#" + objectId, digestMethod, null,
            "http://www.w3.org/2000/09/xmldsig#Object", null);
    references.add(reference);
}