在java中创建xml标记末尾的空间

在java中创建xml标记末尾的空间,java,xml,Java,Xml,我的xml标记是: <Description/> 您所做的错误是对任意未处理的文本进行签名,而不是将文档的规范版本(标记中没有空格,但也具有排序属性、具有相同类型的引号等)提交给数字签名计算 W3C建议指定了一种标准而全面的方法来消除任意差异。没有通用的XML序列化程序能够让您对详细输出进行如此精细的控制。你不需要它。你能给我详细解释一下吗? <Description /> String thisLine = ""; String xm

我的xml标记是:

<Description/>

您所做的错误是对任意未处理的文本进行签名,而不是将文档的规范版本(标记中没有空格,但也具有排序属性、具有相同类型的引号等)提交给数字签名计算


W3C建议指定了一种标准而全面的方法来消除任意差异。

没有通用的XML序列化程序能够让您对详细输出进行如此精细的控制。你不需要它。你能给我详细解释一下吗?
<Description />
        String thisLine = "";
        String xmlString = "";
        BufferedReader br = new BufferedReader(new FileReader(originalXmlFilePath));
        while ((thisLine = br.readLine()) != null) {
            xmlString = xmlString + thisLine.trim();
        }
        br.close();

        ByteArrayInputStream xmlStream = new ByteArrayInputStream(xmlString.getBytes());

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setIgnoringElementContentWhitespace(true);
        dbf.setValidating(false);
        Document doc = dbf.newDocumentBuilder().parse
            (xmlStream );

        doc.setXmlStandalone(true);



        DOMSignContext dsc = new DOMSignContext
            (keyEntry.getPrivateKey(), doc.getDocumentElement());


        javax.xml.crypto.dsig.XMLSignature signature = fac.newXMLSignature(si, ki);


        signature.sign(dsc);


        // Output the resulting document.
    //  OutputStream os = new FileOutputStream(new File(destnSignedXmlFilePath));
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer trans = tf.newTransformer();
         trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

        trans.setOutputProperty(OutputKeys.INDENT, "yes");


        StringWriter writer = new StringWriter();
        trans.transform(new DOMSource(doc), new StreamResult(writer));
        String output = writer.getBuffer().toString();//.replaceAll("\n|\r", "");


        System.out.println("output== "+output);