2
내 단어 XML 파일에 줄 바꿈하지 않는 공백을 사용하고 싶습니다. 나도 알아, 일반 Word에서 나는 Ctrl + Shift + 스페이스를 사용할 수 있습니다; 이것과 잘 작동합니다. 나는 자바를 통해 그 줄 바꿈없는 공백을 넣을 때, 그것은 빈 설정합니다 : 같은자바를 사용하여 단어 xml에 줄 바꿈하지 않는 방법을 삽입하는 방법
내 샘플 코드,
public static void main(String[] args) {
String readpath = "D:/Sathish/TestDocuments/ReadDocument/temp/final/Testing.xml";
Document doc = readDocument(readpath);
NodeList nList = doc.getElementsByTagName("w:body");
Node nNode = nList.item(0);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
NodeList wpList = eElement.getElementsByTagName("w:p");
String tag = "";
for (int temp = 0; temp < wpList.getLength(); temp++) {
Node nWpNode = wpList.item(temp);
if (nWpNode.getNodeType() == Node.ELEMENT_NODE) {
Element wpElement = (Element) nWpNode;
NodeList wrNodeList = wpElement.getChildNodes();
for(int j = 0; j < wrNodeList.getLength(); j++){
Node nWrNode = wrNodeList.item(j);
if (nWrNode.getNodeType() == Node.ELEMENT_NODE) {
Element wrElement = (Element) nWrNode;
NodeList nodeList = wrElement.getElementsByTagName("w:t");
for(int temp1 = 0; temp1 < nodeList.getLength(); temp1++){
Node nWtNode = nodeList.item(temp1);
if (nWtNode.getNodeType() == Node.ELEMENT_NODE) {
Element wtElement = (Element) nWtNode;
tag = wtElement.getTextContent();
//here, matching Conditions..
// It will be set Normal Space
wtElement.setAttribute("xml:space", "preserve");
wtElement.setTextContent(" ");
// I need to set non-breaking space
// ??????????????????????
}
}
}
}
}
}
}
}
나는 비 파괴 공간을 추가 할.
그리고 다른 방법으로도 허용되는 경우.
그럼 알려 주시기 바랍니다 ..
감사합니다.