com.metamatrix.common.xml
Class XmlUtil

java.lang.Object
  extended by com.metamatrix.common.xml.XmlUtil

public class XmlUtil
extends java.lang.Object

Utility class for XML documents and related items.


Method Summary
static java.lang.String containsValidCharacters(java.lang.String str)
          This method helps determine whether a string value (stored as an element or attribute value) are legal characters as defined by XML 1.0.
static java.lang.String escapeCharacterData(java.lang.String text)
          This method will escape any and all characters in the passed in String so that the String can be used as character data in an XML Document without affecting the markup.
static java.lang.String removeInvalidCharacters(java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

containsValidCharacters

public static java.lang.String containsValidCharacters(java.lang.String str)
This method helps determine whether a string value (stored as an element or attribute value) are legal characters as defined by XML 1.0.

XML has a slightly smaller set of legal scalar values than Unicode:

#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]

Parameters:
str - the string to be checked
Returns:
a String with the reason the string is invalid, or null if name is OK.

removeInvalidCharacters

public static java.lang.String removeInvalidCharacters(java.lang.String str)

escapeCharacterData

public static java.lang.String escapeCharacterData(java.lang.String text)
This method will escape any and all characters in the passed in String so that the String can be used as character data in an XML Document without affecting the markup. Essentially the code does the following replacements: > -- > < -- < & -- & " -- " The returned String will be fully escaped. If the passed in String is null, null will be returned from this method.

Parameters:
text - The string to be escaped.
Returns:
the escaped String.


Copyright © 2009. All Rights Reserved.