Revision 8680 trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/catalogClient/metadataXML/XMLTree.java
XMLTree.java | ||
---|---|---|
40 | 40 |
* dac@iver.es |
41 | 41 |
*/ |
42 | 42 |
package es.gva.cit.catalogClient.metadataXML; |
43 |
import java.io.ByteArrayInputStream; |
|
43 | 44 |
import java.io.File; |
44 | 45 |
import java.io.FileWriter; |
45 | 46 |
import java.io.IOException; |
... | ... | |
50 | 51 |
import org.apache.xml.serialize.OutputFormat; |
51 | 52 |
import org.apache.xml.serialize.XMLSerializer; |
52 | 53 |
import org.w3c.dom.Document; |
54 |
|
|
55 |
import es.gva.cit.catalogClient.utils.Strings; |
|
53 | 56 |
/* |
54 | 57 |
* Created on 15-abr-2005 |
55 | 58 |
* |
... | ... | |
98 | 101 |
return null; |
99 | 102 |
} |
100 | 103 |
} |
104 |
|
|
105 |
/** |
|
106 |
* Create a XML node from a String |
|
107 |
* |
|
108 |
* |
|
109 |
* @return XML node |
|
110 |
* @param stream InputStream |
|
111 |
*/ |
|
112 |
public static XMLNode xmlToTree(String string) { |
|
113 |
try { |
|
114 |
return new XMLNode(new ByteArrayInputStream(string.getBytes())); |
|
115 |
} catch (Exception e) { |
|
116 |
// Unconvertible UTF-8 character |
|
117 |
string = Strings.replace(string, |
|
118 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>", |
|
119 |
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); |
|
120 |
try { |
|
121 |
return new XMLNode(new ByteArrayInputStream(string.getBytes())); |
|
122 |
} catch (Exception e1) { |
|
123 |
// TODO Auto-generated catch block |
|
124 |
e1.printStackTrace(); |
|
125 |
return null; |
|
126 |
} |
|
127 |
} |
|
128 |
} |
|
101 | 129 |
|
102 | 130 |
/** |
103 | 131 |
* Devuelve un fichero que crea a partir de un arbol XML |
Also available in: Unified diff