本文整理了Java中org.fcrepo.utilities.xml.XercesXmlSerializers
类的一些代码示例,展示了XercesXmlSerializers
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XercesXmlSerializers
类的具体详情如下:
包路径:org.fcrepo.utilities.xml.XercesXmlSerializers
类名称:XercesXmlSerializers
[英]This class can only be used with the Xerces 2.9.x line; the xml serializers it uses will be removed in Xerces 3.x
[中]该类只能用于Xerces 2.9。x线;它使用的xml序列化程序将在Xerces 3中删除。十、
代码示例来源:origin: fcrepo3/fcrepo
private static void format(Document doc, Writer out) throws Exception {
XercesXmlSerializers.writePrettyPrint(doc, out);
}
代码示例来源:origin: fcrepo3/fcrepo
/**
* Serialize the final WSDL document to the given writer.
*/
public void serialize(Writer out) throws IOException {
XercesXmlSerializers.writeConsoleNoDocType(_wsdlDoc, out);
}
代码示例来源:origin: fcrepo3/fcrepo
public static InputStream fedoraXMLHashFormat(byte[] data) throws Exception {
ReadableCharArrayWriter writer = new ReadableCharArrayWriter();
Document doc =
XmlTransformUtility.parseNamespaceAware(new ByteArrayInputStream(data));
XercesXmlSerializers.writeXmlNoSpace(doc, "UTF-8", writer);
writer.close();
BufferedReader br =
new BufferedReader(writer.toReader());
String line = null;
ReadableByteArrayOutputStream outStream = new ReadableByteArrayOutputStream();
OutputStreamWriter sb = new OutputStreamWriter(outStream, "UTF-8");
while ((line = br.readLine()) != null) {
line = line.trim();
sb.write(line);
}
sb.close();
return outStream.toInputStream();
}
代码示例来源:origin: fcrepo3/fcrepo
OutputStreamWriter writer =
new OutputStreamWriter(outStream, Charset.forName("UTF-8"));
XercesXmlSerializers.writeMgmtNoDecl(doc, writer);
writer.close();
} catch (Exception e) {
代码示例来源:origin: fcrepo3/fcrepo
private void getXML(InputStream in, OutputStream outStream, boolean includeXMLDeclaration) throws GeneralException {
// parse with xerces and re-serialize the fixed xml to a byte array
try {
BufferedWriter out = new BufferedWriter(
new OutputStreamWriter(outStream, Charset.forName("UTF-8")));
Document doc =
XmlTransformUtility.parseNamespaceAware(in);
if (includeXMLDeclaration) {
XercesXmlSerializers.writeMgmtWithDecl(doc, out);
} else {
XercesXmlSerializers.writeMgmtNoDecl(doc, out);
}
out.flush();
} catch (Exception e) {
String message = e.getMessage();
if (message == null) {
message = "";
}
throw new GeneralException("XML was not well-formed. " + message, e);
}
}
private void checkDatastreamID(String id) throws ValidationException {
代码示例来源:origin: fcrepo3/fcrepo
private static void prettyPrint(InputStream source,
OutputStream destination)
throws Exception {
BufferedWriter outWriter = new BufferedWriter(new PrintWriter(destination));
DocumentBuilder builder = XmlTransformUtility.borrowDocumentBuilder();
try {
Document doc = builder.parse(source);
XercesXmlSerializers.writeConsoleWithDocType(doc, outWriter);
outWriter.close();
} finally {
XmlTransformUtility.returnDocumentBuilder(builder);
}
}
代码示例来源:origin: fcrepo3/fcrepo
/**
* Serialize the dom Document with no preserved space between elements,
* but without indenting, line wrapping, omission of XML declaration, or
* omission of doctype
* @param doc
* @param encoding
* @param out
* @throws IOException
*/
public static void writeXmlNoSpace(Document doc, String encoding, Writer out)
throws IOException {
XMLSerializer ser = new XMLSerializer(out, getXmlNoSpace(encoding));
ser.serialize(doc);
out.close();
}
代码示例来源:origin: fcrepo3/fcrepo
public static byte[] fedoraXMLHashFormat(byte[] data) throws Exception {
ReadableCharArrayWriter writer = new ReadableCharArrayWriter();
DocumentBuilder builder = XmlTransformUtility.borrowDocumentBuilder();
try {
Document doc = builder.parse(new ByteArrayInputStream(data));
XercesXmlSerializers.writeXmlNoSpace(doc, "UTF-8", writer);
writer.close();
} finally {
XmlTransformUtility.returnDocumentBuilder(builder);
}
BufferedReader br =
new BufferedReader(writer.toReader());
String line = null;
ReadableByteArrayOutputStream outStream = new ReadableByteArrayOutputStream();
OutputStreamWriter sb = new OutputStreamWriter(outStream, "UTF-8");
while ((line = br.readLine()) != null) {
line = line.trim();
sb.write(line);
}
sb.close();
return outStream.toByteArray();
}
代码示例来源:origin: fcrepo3/fcrepo
Document doc = XmlTransformUtility.parseNamespaceAware(data);
XercesXmlSerializers.writeMgmtNoDecl(doc, buf);
buf.close();
content = buf.getString();
代码示例来源:origin: org.fcrepo/fcrepo-server
private void getXML(InputStream in, OutputStream outStream, boolean includeXMLDeclaration) throws GeneralException {
// parse with xerces and re-serialize the fixed xml to a byte array
try {
BufferedWriter out = new BufferedWriter(
new OutputStreamWriter(outStream, Charset.forName("UTF-8")));
Document doc =
XmlTransformUtility.parseNamespaceAware(in);
if (includeXMLDeclaration) {
XercesXmlSerializers.writeMgmtWithDecl(doc, out);
} else {
XercesXmlSerializers.writeMgmtNoDecl(doc, out);
}
out.flush();
} catch (Exception e) {
String message = e.getMessage();
if (message == null) {
message = "";
}
throw new GeneralException("XML was not well-formed. " + message, e);
}
}
private void checkDatastreamID(String id) throws ValidationException {
代码示例来源:origin: org.fcrepo/fcrepo-server
private static void prettyPrint(InputStream source,
OutputStream destination)
throws Exception {
BufferedWriter outWriter = new BufferedWriter(new PrintWriter(destination));
DocumentBuilder builder = XmlTransformUtility.borrowDocumentBuilder();
try {
Document doc = builder.parse(source);
XercesXmlSerializers.writeConsoleWithDocType(doc, outWriter);
outWriter.close();
} finally {
XmlTransformUtility.returnDocumentBuilder(builder);
}
}
代码示例来源:origin: org.fcrepo/fcrepo-common
/**
* Serialize the dom Document with no preserved space between elements,
* but without indenting, line wrapping, omission of XML declaration, or
* omission of doctype
* @param doc
* @param encoding
* @param out
* @throws IOException
*/
public static void writeXmlNoSpace(Document doc, String encoding, Writer out)
throws IOException {
XMLSerializer ser = new XMLSerializer(out, getXmlNoSpace(encoding));
ser.serialize(doc);
out.close();
}
代码示例来源:origin: fcrepo3/fcrepo
builder = XmlTransformUtility.borrowDocumentBuilder();
Document doc = builder.parse(new ByteArrayInputStream(xmlContent));
XercesXmlSerializers.writeXmlNoSpace(doc, m_encoding, out);
out.close();
} finally {
代码示例来源:origin: fcrepo3/fcrepo
new OutputStreamWriter(outStream, Charset.forName("UTF-8"));
XercesXmlSerializers.writeMgmtNoDecl(doc, writer);
writer.close();
代码示例来源:origin: fcrepo3/fcrepo
private static void format(Document doc, Writer out) throws Exception {
XercesXmlSerializers.writePrettyPrint(doc, out);
}
}
代码示例来源:origin: org.fcrepo/fcrepo-server
/**
* Serialize the final WSDL document to the given writer.
*/
public void serialize(Writer out) throws IOException {
XercesXmlSerializers.writeConsoleNoDocType(_wsdlDoc, out);
}
代码示例来源:origin: org.fcrepo/fcrepo-server
builder = XmlTransformUtility.borrowDocumentBuilder();
Document doc = builder.parse(new ByteArrayInputStream(xmlContent));
XercesXmlSerializers.writeXmlNoSpace(doc, m_encoding, out);
out.close();
} finally {
代码示例来源:origin: fcrepo3/fcrepo
@SuppressWarnings("deprecation")
private void testWriteMgmtNoDecl(Document doc) throws Exception {
StringWriter sout = new StringWriter();
SunXmlSerializers.writeMgmtNoDecl(doc, sout);
String proprietary = sout.toString();
sout = new StringWriter();
XercesXmlSerializers.writeMgmtNoDecl(doc, sout);
String standard = sout.toString();
if (!proprietary.equals(standard)) {
System.out.println("<<<<");
System.out.println(proprietary);
System.out.println(">>>>");
System.out.println(standard);
}
assertEquals(proprietary, standard);
}
代码示例来源:origin: fcrepo3/fcrepo
private static void format(Document doc, Writer out) throws Exception {
XercesXmlSerializers.writePrettyPrint(doc, out);
}
代码示例来源:origin: fcrepo3/fcrepo
@SuppressWarnings("deprecation")
private void testWriteConsoleNoDocType(Document doc) throws Exception {
StringWriter sout = new StringWriter();
SunXmlSerializers.writeConsoleNoDocType(doc, sout);
String proprietary = sout.toString();
sout = new StringWriter();
XercesXmlSerializers.writeConsoleNoDocType(doc, sout);
String standard = sout.toString();
if (!proprietary.equals(standard)) {
System.out.println("<<<<");
System.out.println(proprietary);
System.out.println(">>>>");
System.out.println(standard);
}
assertEquals(proprietary, standard);
}
内容来源于网络,如有侵权,请联系作者删除!