Class XmlHelper


  • public class XmlHelper
    extends java.lang.Object

    Überschrift: XmlHelper.

    Beschreibung: Hilfsklasse für das Lesen und Schreiben von XML-Dateien.

    Copyright: Copyright (c) ELO Digital Office GmbH 2018

    • Constructor Summary

      Constructors 
      Constructor Description
      XmlHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void convertToPdf​(java.io.File foFile, java.io.File pdfFile)
      Konvertiert die angegebene FO-Datei nach PDF.
      static void convertToPdf​(java.io.File xmlFile, java.io.File xslFile, java.io.File pdfFile)
      Konvertiert die angegebene XML-Datei zu einer PDF-Datei mit Hilfe der angegebenen XSL-Datei.
      static void convertToPdf​(java.io.InputStream foStream, java.io.OutputStream pdfStream)
      Konvertiert die angegebene FO-Datei nach PDF.
      static java.lang.String formatXmlText​(java.lang.String unformattedXmlText, int lineWidth, int indent)
      Liefert den formattierten XML-Text aus dem angegebenen nicht formattierten XML-Text zurück.
      static org.apache.avalon.framework.configuration.Configuration getConfigFromNode​(org.w3c.dom.Node node)
      Erzeugt eine Konfiguration für den angegebenen XML-Knoten.
      static org.apache.avalon.framework.configuration.Configuration getConfiguration​(java.io.File configFile)
      Liefert ein Konfigurationsobjekt aus der angegebenen Konfigurationsdatei zurück.
      static java.lang.String getDocumentContent​(java.io.File xmlFile, boolean withDeclaration, boolean standalone)
      Liefert den Dokumentinhalt als ein String zurück.
      static java.lang.String getDocumentContent​(org.w3c.dom.Document xmlDoc, boolean withDeclaration, boolean standalone)
      Liefert den Dokumentinhalt als ein String zurück.
      static org.w3c.dom.Document getDocumentFromString​(java.lang.String docContent)
      Liefert ein XML-Dokument aus dem angegebenen String zurück.
      static java.lang.String getEncoding​(java.io.File xmlFile)
      Liefert die Kodierung der angegebenen XML-Datei zurück.
      static java.lang.String getItemValue​(java.io.File xmlFile, java.lang.String xPathExpression)
      Liefert den Text des angegebenen aktuellen Knotens zurück.
      static java.lang.String getNodeValue​(java.io.File xmlFile, java.lang.String xPathExpression)
      Liefert den Wert für den angegebenen Knoten zurück.
      static int selectNodes​(java.io.File xmlFile, java.lang.String xPathExpression)
      Evaluiert die angegebenen XML-Knoten und liefert die Anzahl der evaluierten Knoten zurück.
      static void transform​(java.io.File xmlFile, java.io.File xslFile, java.io.File resultXmlFile)  
      static void writeKeywordingInXml​(de.elo.ix.client.Sord sord, java.io.File xmlFile)
      Schreibt die Verschlagwortung in einer XML-Datei.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XmlHelper

        public XmlHelper()
    • Method Detail

      • writeKeywordingInXml

        public static void writeKeywordingInXml​(de.elo.ix.client.Sord sord,
                                                java.io.File xmlFile)
                                         throws java.lang.Exception
        Schreibt die Verschlagwortung in einer XML-Datei.
        Parameters:
        sord - Verschlagwortung eines Archiveintrags
        xmlFile - XML-Datei
        Throws:
        java.lang.Exception
      • getDocumentContent

        public static java.lang.String getDocumentContent​(org.w3c.dom.Document xmlDoc,
                                                          boolean withDeclaration,
                                                          boolean standalone)
                                                   throws javax.xml.transform.TransformerException,
                                                          java.lang.Exception
        Liefert den Dokumentinhalt als ein String zurück.
        Parameters:
        xmlDoc - XML-Dokument
        withDeclaration - Ausgabe mit einer XML-Deklaration
        standalone - Standalone Dokument Deklaration
        Returns:
        Dokumentinhalt als String
        Throws:
        javax.xml.transform.TransformerException
        java.lang.Exception
      • getDocumentContent

        public static java.lang.String getDocumentContent​(java.io.File xmlFile,
                                                          boolean withDeclaration,
                                                          boolean standalone)
                                                   throws javax.xml.transform.TransformerException,
                                                          java.lang.Exception
        Liefert den Dokumentinhalt als ein String zurück.
        Parameters:
        xmlFile - XML-Datei
        withDeclaration - Ausgabe mit einer XML-Deklaration
        standalone - Standalone Dokument Deklaration
        Returns:
        Dokumentinhalt als String
        Throws:
        javax.xml.transform.TransformerException
        java.lang.Exception
      • getDocumentFromString

        public static org.w3c.dom.Document getDocumentFromString​(java.lang.String docContent)
                                                          throws javax.xml.parsers.ParserConfigurationException,
                                                                 org.xml.sax.SAXException,
                                                                 java.io.IOException,
                                                                 java.lang.Exception
        Liefert ein XML-Dokument aus dem angegebenen String zurück.
        Parameters:
        docContent - Dokumentinhalt
        Returns:
        XML-Dokument
        Throws:
        javax.xml.parsers.ParserConfigurationException
        org.xml.sax.SAXException
        java.io.IOException
        java.lang.Exception
      • getNodeValue

        public static java.lang.String getNodeValue​(java.io.File xmlFile,
                                                    java.lang.String xPathExpression)
                                             throws java.lang.Exception
        Liefert den Wert für den angegebenen Knoten zurück.
        Parameters:
        xmlFile - XML-Datei
        xPathExpression - XPath-Ausdruck
        Returns:
        Ergebnis
        Throws:
        java.lang.Exception
      • selectNodes

        public static int selectNodes​(java.io.File xmlFile,
                                      java.lang.String xPathExpression)
                               throws java.lang.Exception
        Evaluiert die angegebenen XML-Knoten und liefert die Anzahl der evaluierten Knoten zurück.
        Parameters:
        xmlFile - XML-Datei
        xPathExpression - XPath-Ausdruck
        Returns:
        Anzahl der evaluierten XML-Knoten
        Throws:
        java.lang.Exception
      • getItemValue

        public static java.lang.String getItemValue​(java.io.File xmlFile,
                                                    java.lang.String xPathExpression)
                                             throws java.lang.Exception
        Liefert den Text des angegebenen aktuellen Knotens zurück.
        Parameters:
        xmlFile - XML-Datei
        xPathExpression - Pfad zum aktuellen Knoten
        Returns:
        Text des aktuellen Knotens
        Throws:
        java.lang.Exception
      • convertToPdf

        public static void convertToPdf​(java.io.File xmlFile,
                                        java.io.File xslFile,
                                        java.io.File pdfFile)
                                 throws java.lang.Exception
        Konvertiert die angegebene XML-Datei zu einer PDF-Datei mit Hilfe der angegebenen XSL-Datei. Die XSL-Datei enthält die Transformationsregeln.
        Parameters:
        xmlFile - XML-Datei
        xslFile - XSL-Datei
        pdfFile - PDF-Datei
        Throws:
        java.lang.Exception
      • transform

        public static void transform​(java.io.File xmlFile,
                                     java.io.File xslFile,
                                     java.io.File resultXmlFile)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • convertToPdf

        public static void convertToPdf​(java.io.File foFile,
                                        java.io.File pdfFile)
                                 throws java.lang.Exception
        Konvertiert die angegebene FO-Datei nach PDF.
        Parameters:
        foFile - FO-Datei
        pdfFile - PDF-Datei
        Throws:
        java.lang.Exception
      • convertToPdf

        public static void convertToPdf​(java.io.InputStream foStream,
                                        java.io.OutputStream pdfStream)
                                 throws java.lang.Exception
        Konvertiert die angegebene FO-Datei nach PDF. Dabei werden die Betriebssystemschriften unterstützt.
        Parameters:
        foStream - InputStream für die FO-Datei
        pdfStream - OutputStream für die PDF-Datei
        Throws:
        java.lang.Exception
      • formatXmlText

        public static java.lang.String formatXmlText​(java.lang.String unformattedXmlText,
                                                     int lineWidth,
                                                     int indent)
                                              throws java.lang.Exception
        Liefert den formattierten XML-Text aus dem angegebenen nicht formattierten XML-Text zurück.
        Parameters:
        unformattedXmlText - nicht formattierter XML-Text
        lineWidth - Zeilenbreite
        indent - Zeileneinzug
        Returns:
        formattierter XML-Text
        Throws:
        java.lang.Exception
      • getEncoding

        public static java.lang.String getEncoding​(java.io.File xmlFile)
                                            throws java.lang.Exception
        Liefert die Kodierung der angegebenen XML-Datei zurück.
        Parameters:
        xmlFile - XML-Datei
        Returns:
        Kodierung der XML-Datei
        Throws:
        java.lang.Exception
      • getConfiguration

        public static org.apache.avalon.framework.configuration.Configuration getConfiguration​(java.io.File configFile)
                                                                                        throws java.lang.Exception
        Liefert ein Konfigurationsobjekt aus der angegebenen Konfigurationsdatei zurück.
        Parameters:
        configFile - Konfigurationsdatei
        Returns:
        Konfigurationsobjekt
        Throws:
        java.lang.Exception
      • getConfigFromNode

        public static org.apache.avalon.framework.configuration.Configuration getConfigFromNode​(org.w3c.dom.Node node)
                                                                                         throws java.lang.Exception
        Erzeugt eine Konfiguration für den angegebenen XML-Knoten.
        Parameters:
        node - HTML-Knoten
        Returns:
        Konfiguration
        Throws:
        java.lang.Exception