org.fcrepo.utilities.xml.XercesXmlSerializers类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.fcrepo.utilities.xml.XercesXmlSerializers类的一些代码示例,展示了XercesXmlSerializers类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XercesXmlSerializers类的具体详情如下:
包路径:org.fcrepo.utilities.xml.XercesXmlSerializers
类名称: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

  1. private static void format(Document doc, Writer out) throws Exception {
  2. XercesXmlSerializers.writePrettyPrint(doc, out);
  3. }

代码示例来源:origin: fcrepo3/fcrepo

  1. /**
  2. * Serialize the final WSDL document to the given writer.
  3. */
  4. public void serialize(Writer out) throws IOException {
  5. XercesXmlSerializers.writeConsoleNoDocType(_wsdlDoc, out);
  6. }

代码示例来源:origin: fcrepo3/fcrepo

  1. public static InputStream fedoraXMLHashFormat(byte[] data) throws Exception {
  2. ReadableCharArrayWriter writer = new ReadableCharArrayWriter();
  3. Document doc =
  4. XmlTransformUtility.parseNamespaceAware(new ByteArrayInputStream(data));
  5. XercesXmlSerializers.writeXmlNoSpace(doc, "UTF-8", writer);
  6. writer.close();
  7. BufferedReader br =
  8. new BufferedReader(writer.toReader());
  9. String line = null;
  10. ReadableByteArrayOutputStream outStream = new ReadableByteArrayOutputStream();
  11. OutputStreamWriter sb = new OutputStreamWriter(outStream, "UTF-8");
  12. while ((line = br.readLine()) != null) {
  13. line = line.trim();
  14. sb.write(line);
  15. }
  16. sb.close();
  17. return outStream.toInputStream();
  18. }

代码示例来源:origin: fcrepo3/fcrepo

  1. OutputStreamWriter writer =
  2. new OutputStreamWriter(outStream, Charset.forName("UTF-8"));
  3. XercesXmlSerializers.writeMgmtNoDecl(doc, writer);
  4. writer.close();
  5. } catch (Exception e) {

代码示例来源:origin: fcrepo3/fcrepo

  1. private void getXML(InputStream in, OutputStream outStream, boolean includeXMLDeclaration) throws GeneralException {
  2. // parse with xerces and re-serialize the fixed xml to a byte array
  3. try {
  4. BufferedWriter out = new BufferedWriter(
  5. new OutputStreamWriter(outStream, Charset.forName("UTF-8")));
  6. Document doc =
  7. XmlTransformUtility.parseNamespaceAware(in);
  8. if (includeXMLDeclaration) {
  9. XercesXmlSerializers.writeMgmtWithDecl(doc, out);
  10. } else {
  11. XercesXmlSerializers.writeMgmtNoDecl(doc, out);
  12. }
  13. out.flush();
  14. } catch (Exception e) {
  15. String message = e.getMessage();
  16. if (message == null) {
  17. message = "";
  18. }
  19. throw new GeneralException("XML was not well-formed. " + message, e);
  20. }
  21. }
  22. private void checkDatastreamID(String id) throws ValidationException {

代码示例来源:origin: fcrepo3/fcrepo

  1. private static void prettyPrint(InputStream source,
  2. OutputStream destination)
  3. throws Exception {
  4. BufferedWriter outWriter = new BufferedWriter(new PrintWriter(destination));
  5. DocumentBuilder builder = XmlTransformUtility.borrowDocumentBuilder();
  6. try {
  7. Document doc = builder.parse(source);
  8. XercesXmlSerializers.writeConsoleWithDocType(doc, outWriter);
  9. outWriter.close();
  10. } finally {
  11. XmlTransformUtility.returnDocumentBuilder(builder);
  12. }
  13. }

代码示例来源:origin: fcrepo3/fcrepo

  1. /**
  2. * Serialize the dom Document with no preserved space between elements,
  3. * but without indenting, line wrapping, omission of XML declaration, or
  4. * omission of doctype
  5. * @param doc
  6. * @param encoding
  7. * @param out
  8. * @throws IOException
  9. */
  10. public static void writeXmlNoSpace(Document doc, String encoding, Writer out)
  11. throws IOException {
  12. XMLSerializer ser = new XMLSerializer(out, getXmlNoSpace(encoding));
  13. ser.serialize(doc);
  14. out.close();
  15. }

代码示例来源:origin: fcrepo3/fcrepo

  1. public static byte[] fedoraXMLHashFormat(byte[] data) throws Exception {
  2. ReadableCharArrayWriter writer = new ReadableCharArrayWriter();
  3. DocumentBuilder builder = XmlTransformUtility.borrowDocumentBuilder();
  4. try {
  5. Document doc = builder.parse(new ByteArrayInputStream(data));
  6. XercesXmlSerializers.writeXmlNoSpace(doc, "UTF-8", writer);
  7. writer.close();
  8. } finally {
  9. XmlTransformUtility.returnDocumentBuilder(builder);
  10. }
  11. BufferedReader br =
  12. new BufferedReader(writer.toReader());
  13. String line = null;
  14. ReadableByteArrayOutputStream outStream = new ReadableByteArrayOutputStream();
  15. OutputStreamWriter sb = new OutputStreamWriter(outStream, "UTF-8");
  16. while ((line = br.readLine()) != null) {
  17. line = line.trim();
  18. sb.write(line);
  19. }
  20. sb.close();
  21. return outStream.toByteArray();
  22. }

代码示例来源:origin: fcrepo3/fcrepo

  1. Document doc = XmlTransformUtility.parseNamespaceAware(data);
  2. XercesXmlSerializers.writeMgmtNoDecl(doc, buf);
  3. buf.close();
  4. content = buf.getString();

代码示例来源:origin: org.fcrepo/fcrepo-server

  1. private void getXML(InputStream in, OutputStream outStream, boolean includeXMLDeclaration) throws GeneralException {
  2. // parse with xerces and re-serialize the fixed xml to a byte array
  3. try {
  4. BufferedWriter out = new BufferedWriter(
  5. new OutputStreamWriter(outStream, Charset.forName("UTF-8")));
  6. Document doc =
  7. XmlTransformUtility.parseNamespaceAware(in);
  8. if (includeXMLDeclaration) {
  9. XercesXmlSerializers.writeMgmtWithDecl(doc, out);
  10. } else {
  11. XercesXmlSerializers.writeMgmtNoDecl(doc, out);
  12. }
  13. out.flush();
  14. } catch (Exception e) {
  15. String message = e.getMessage();
  16. if (message == null) {
  17. message = "";
  18. }
  19. throw new GeneralException("XML was not well-formed. " + message, e);
  20. }
  21. }
  22. private void checkDatastreamID(String id) throws ValidationException {

代码示例来源:origin: org.fcrepo/fcrepo-server

  1. private static void prettyPrint(InputStream source,
  2. OutputStream destination)
  3. throws Exception {
  4. BufferedWriter outWriter = new BufferedWriter(new PrintWriter(destination));
  5. DocumentBuilder builder = XmlTransformUtility.borrowDocumentBuilder();
  6. try {
  7. Document doc = builder.parse(source);
  8. XercesXmlSerializers.writeConsoleWithDocType(doc, outWriter);
  9. outWriter.close();
  10. } finally {
  11. XmlTransformUtility.returnDocumentBuilder(builder);
  12. }
  13. }

代码示例来源:origin: org.fcrepo/fcrepo-common

  1. /**
  2. * Serialize the dom Document with no preserved space between elements,
  3. * but without indenting, line wrapping, omission of XML declaration, or
  4. * omission of doctype
  5. * @param doc
  6. * @param encoding
  7. * @param out
  8. * @throws IOException
  9. */
  10. public static void writeXmlNoSpace(Document doc, String encoding, Writer out)
  11. throws IOException {
  12. XMLSerializer ser = new XMLSerializer(out, getXmlNoSpace(encoding));
  13. ser.serialize(doc);
  14. out.close();
  15. }

代码示例来源:origin: fcrepo3/fcrepo

  1. builder = XmlTransformUtility.borrowDocumentBuilder();
  2. Document doc = builder.parse(new ByteArrayInputStream(xmlContent));
  3. XercesXmlSerializers.writeXmlNoSpace(doc, m_encoding, out);
  4. out.close();
  5. } finally {

代码示例来源:origin: fcrepo3/fcrepo

  1. new OutputStreamWriter(outStream, Charset.forName("UTF-8"));
  2. XercesXmlSerializers.writeMgmtNoDecl(doc, writer);
  3. writer.close();

代码示例来源:origin: fcrepo3/fcrepo

  1. private static void format(Document doc, Writer out) throws Exception {
  2. XercesXmlSerializers.writePrettyPrint(doc, out);
  3. }
  4. }

代码示例来源:origin: org.fcrepo/fcrepo-server

  1. /**
  2. * Serialize the final WSDL document to the given writer.
  3. */
  4. public void serialize(Writer out) throws IOException {
  5. XercesXmlSerializers.writeConsoleNoDocType(_wsdlDoc, out);
  6. }

代码示例来源:origin: org.fcrepo/fcrepo-server

  1. builder = XmlTransformUtility.borrowDocumentBuilder();
  2. Document doc = builder.parse(new ByteArrayInputStream(xmlContent));
  3. XercesXmlSerializers.writeXmlNoSpace(doc, m_encoding, out);
  4. out.close();
  5. } finally {

代码示例来源:origin: fcrepo3/fcrepo

  1. @SuppressWarnings("deprecation")
  2. private void testWriteMgmtNoDecl(Document doc) throws Exception {
  3. StringWriter sout = new StringWriter();
  4. SunXmlSerializers.writeMgmtNoDecl(doc, sout);
  5. String proprietary = sout.toString();
  6. sout = new StringWriter();
  7. XercesXmlSerializers.writeMgmtNoDecl(doc, sout);
  8. String standard = sout.toString();
  9. if (!proprietary.equals(standard)) {
  10. System.out.println("<<<<");
  11. System.out.println(proprietary);
  12. System.out.println(">>>>");
  13. System.out.println(standard);
  14. }
  15. assertEquals(proprietary, standard);
  16. }

代码示例来源:origin: fcrepo3/fcrepo

  1. private static void format(Document doc, Writer out) throws Exception {
  2. XercesXmlSerializers.writePrettyPrint(doc, out);
  3. }

代码示例来源:origin: fcrepo3/fcrepo

  1. @SuppressWarnings("deprecation")
  2. private void testWriteConsoleNoDocType(Document doc) throws Exception {
  3. StringWriter sout = new StringWriter();
  4. SunXmlSerializers.writeConsoleNoDocType(doc, sout);
  5. String proprietary = sout.toString();
  6. sout = new StringWriter();
  7. XercesXmlSerializers.writeConsoleNoDocType(doc, sout);
  8. String standard = sout.toString();
  9. if (!proprietary.equals(standard)) {
  10. System.out.println("<<<<");
  11. System.out.println(proprietary);
  12. System.out.println(">>>>");
  13. System.out.println(standard);
  14. }
  15. assertEquals(proprietary, standard);
  16. }

相关文章