Changeset 26561
- Timestamp:
- 2012-12-06T15:48:18+13:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DebugService.java
r26556 r26561 16 16 import org.w3c.dom.Document; 17 17 import org.w3c.dom.Element; 18 import org.w3c.dom.NamedNodeMap; 19 import org.w3c.dom.Node; 18 20 import org.w3c.dom.NodeList; 19 21 … … 127 129 if (template.getAttribute("name").equals(nameToGet)) 128 130 { 131 fixAttributes(template); 132 129 133 Element requestedTemplate = this.doc.createElement("requestedNameTemplate"); 130 134 requestedTemplate.appendChild(this.doc.importNode(template, true)); … … 142 146 if (template.getAttribute("match").equals(matchToGet)) 143 147 { 148 fixAttributes(template); 149 144 150 Element requestedTemplate = this.doc.createElement("requestedMatchTemplate"); 145 151 requestedTemplate.appendChild(this.doc.importNode(template, true)); … … 151 157 152 158 return result; 159 } 160 161 protected void fixAttributes(Element template) 162 { 163 NodeList nodes = template.getElementsByTagName("*"); 164 for (int j = 0; j < nodes.getLength(); j++) 165 { 166 Node current = nodes.item(j); 167 NamedNodeMap attributes = current.getAttributes(); 168 for (int k = 0; k < attributes.getLength(); k++) 169 { 170 Node currentAttr = attributes.item(k); 171 String value = currentAttr.getNodeValue(); 172 if (value.contains("&") || value.contains("<") || value.contains(">")) 173 { 174 currentAttr.setNodeValue(value.replace("&", "&amp;").replace("<", "<").replace(">", ">")); 175 } 176 } 177 } 153 178 } 154 179 … … 207 232 NodeList templateElems = xslDoc.getElementsByTagNameNS(fullNamespace, nodeName); 208 233 209 /*210 * NodeList textElems =211 * xslDoc.getElementsByTagNameNS(GSXML.XSL_NAMESPACE, "text"); for212 * (int i = 0; i < textElems.getLength(); i++) {213 * System.err.println("\n\n" + i + "\n\n" +214 * GSXML.xmlNodeToString(textElems.item(i))); }215 */216 217 234 boolean found = false; 218 235 if (nameToSave != null && nameToSave.length() != 0) … … 225 242 try 226 243 { 227 System.err.println(xml);228 244 Element newTemplate = (Element) converter.getDOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"" + GSXML.XSL_NAMESPACE + "\" xmlns:java=\"" + GSXML.JAVA_NAMESPACE + "\" xmlns:util=\"" + GSXML.UTIL_NAMESPACE + "\" xmlns:gsf=\"" + GSXML.GSF_NAMESPACE + "\">" + xml + "</xsl:stylesheet>", "UTF-8").getDocumentElement().getElementsByTagNameNS(fullNamespace, nodeName).item(0); 229 245 template.getParentNode().replaceChild(xslDoc.importNode(newTemplate, true), template);
Note:
See TracChangeset
for help on using the changeset viewer.