Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.rgw.tools
Class XMLTool

java.lang.Object
  extended by ch.rgw.tools.XMLTool

public class XMLTool
extends java.lang.Object

This class provides various helper methods for handling XML data.

Author:
danlutz

Constructor Summary
XMLTool()
           
 
Method Summary
static java.lang.String dateTimeToXmlDateTime(java.lang.String dateTime)
          Convert a TimeTool into an XML dateTime type
static java.lang.String dateToXmlDate(java.lang.String date)
          Copnvert a date part of a TimeTool to an XML date type
static java.lang.String doubleToXmlDouble(double value, int factionalDigits)
          Convert a double value to String conforming to the double datatype of the XML specification.
static Element HashMapToXML(java.util.HashMap<java.lang.String,java.lang.Object> hash, java.lang.String name, Namespace ns)
          Convert a HashMap of String/Object pairs into a SOAP compatible XML structure.
static java.lang.String idToXMLID(java.lang.String id)
          Conversion betweeen Elexis id's and XML ID types.
static java.lang.String moneyToXmlDouble(Money money)
           
static java.util.List<java.lang.String> validateSchema(java.lang.String xmlDocumentUrl)
           
static java.util.List<java.lang.String> validateSchema(java.lang.String schemaUrl, javax.xml.transform.Source source)
           
static java.util.List<java.lang.String> validateSchema(java.lang.String schemaUrl, java.lang.String xmlDocumentUrl)
           
static boolean writeXMLDocument(Document doc, java.lang.String dest)
           
static Money xmlDoubleToMoney(java.lang.String xmlDouble)
           
static java.lang.String xmlIDtoID(java.lang.String xmlid)
          Since elexis id's never contain the letter "x" we can be sure that a starting letter x can be removed to leave us with the original elexis id
static java.lang.String XMLTableToCSVTable(Element table, java.lang.String separator)
          Convert a XML-Table formatted like <table> <row> <col1>Col 1<col1/> <col2>Col 2<col2/> </row> <row> ...
static java.lang.String XMLTableToHTMLTable(Element table)
          Convert a XML-Table formatted like <table> <row> <col1>Col 1<col1/> <col2>Col 2<col2/> </row> <row> ...
static java.util.HashMap<java.lang.String,java.lang.Object> XMLToHashMap(Element elem)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLTool

public XMLTool()
Method Detail

validateSchema

public static java.util.List<java.lang.String> validateSchema(java.lang.String xmlDocumentUrl)

validateSchema

public static java.util.List<java.lang.String> validateSchema(java.lang.String schemaUrl,
                                                              javax.xml.transform.Source source)

validateSchema

public static java.util.List<java.lang.String> validateSchema(java.lang.String schemaUrl,
                                                              java.lang.String xmlDocumentUrl)

moneyToXmlDouble

public static java.lang.String moneyToXmlDouble(Money money)

xmlDoubleToMoney

public static Money xmlDoubleToMoney(java.lang.String xmlDouble)
                              throws java.lang.NumberFormatException
Throws:
java.lang.NumberFormatException

doubleToXmlDouble

public static java.lang.String doubleToXmlDouble(double value,
                                                 int factionalDigits)
Convert a double value to String conforming to the double datatype of the XML specification. (This means mainly, that we have to use the swiss "." also if the PC's locale is set to germany or austria.)

Parameters:
value - the value to be converted
factionalDigits - the number of digits after the point
Returns:
the formated String

XMLTableToCSVTable

public static java.lang.String XMLTableToCSVTable(Element table,
                                                  java.lang.String separator)
Convert a XML-Table formatted like <table> <row> <col1>Col 1<col1/> <col2>Col 2<col2/> </row> <row> ... </row> </table> to a csv table

Parameters:
table - the table to convert
separator - String that separates columns
Returns:
a string containing the csv table. Rows separated by \n, colums separated by separator

XMLTableToHTMLTable

public static java.lang.String XMLTableToHTMLTable(Element table)
Convert a XML-Table formatted like <table> <row> <col1>Col 1<col1/> <col2>Col 2<col2/> </row> <row> ... </row> </table> to a html table

Parameters:
table - the table to convert
Returns:
a string containing the html table.

idToXMLID

public static java.lang.String idToXMLID(java.lang.String id)
Conversion betweeen Elexis id's and XML ID types. XML id types must not begin with a number but may contain letters and numbers. Elexis ID's are always hexadecimal strings thus will never contain a letter other than a-f but might start with a number. Thus if it starts with a number, we prefix an "x"

Parameters:
id - an elexis id
Returns:
a String conforming to tghe XML ID type

xmlIDtoID

public static java.lang.String xmlIDtoID(java.lang.String xmlid)
Since elexis id's never contain the letter "x" we can be sure that a starting letter x can be removed to leave us with the original elexis id

Parameters:
xmlid - an XML ID
Returns:
the conforming elexis id

dateTimeToXmlDateTime

public static java.lang.String dateTimeToXmlDateTime(java.lang.String dateTime)
Convert a TimeTool into an XML dateTime type

Parameters:
dateTime -
Returns:

dateToXmlDate

public static java.lang.String dateToXmlDate(java.lang.String date)
Copnvert a date part of a TimeTool to an XML date type

Parameters:
date -
Returns:

HashMapToXML

public static Element HashMapToXML(java.util.HashMap<java.lang.String,java.lang.Object> hash,
                                   java.lang.String name,
                                   Namespace ns)
Convert a HashMap of String/Object pairs into a SOAP compatible XML structure. Ad this time, only String, int, long, byte, byte[] and Hashmaps thereof are supported as Object types

Parameters:
hash -
name -
ns -
Returns:

XMLToHashMap

public static java.util.HashMap<java.lang.String,java.lang.Object> XMLToHashMap(Element elem)

writeXMLDocument

public static boolean writeXMLDocument(Document doc,
                                       java.lang.String dest)

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis