com.partnersoft.formats.xml
Class XmlLib

java.lang.Object
  extended by com.partnersoft.formats.xml.XmlLib
All Implemented Interfaces:
Lib

public class XmlLib
extends java.lang.Object
implements Lib

Useful XMLish functions.

Copyright 2003-2009 Partner Software, Inc.

Version:
$Id: XmlLib.java 2139 2009-10-03 00:04:53Z paul $
Author:
Russell Cagle, Paul Reavis

Method Summary
static java.lang.String escapeAttribute(java.lang.String original)
          Replaces reserved XML characters with entity references.
static java.lang.String escapeContent(java.lang.String original)
          Replaces reserved XML characters with entity references.
static java.lang.String stripTags(java.lang.String original)
          Removes all tags and returns remaining String contents.
static java.lang.String unescape(java.lang.String original)
          Replaces entity references for XML reserved characters with their character form.
static boolean validate(java.io.Reader reader)
          Validates the given XML stream.
static boolean validate(java.lang.String xml)
          Validates the given XML string.
static boolean validate(VfsFile file)
          Validates the given XML file.
static boolean validateAgainstSchema(java.io.Reader reader, VfsFile schemaFile)
          Validates the given XML stream against its schema.
static boolean validateAgainstSchema(java.lang.String xml, VfsFile schemaFile)
          Validates the given XML string against a schema.
static boolean validateAgainstSchema(VfsFile file, VfsFile schemaFile)
          Validates the given XML file against a schema.
static boolean validateAgainstSchemas(VfsFile file, VfsFile... schemaFiles)
          Validates the given XML file against a list of schemas.
static javax.xml.validation.SchemaFactory xsdSchemaFactory()
          Returns a singleton SchemaFactory for .xsd schemas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

xsdSchemaFactory

public static javax.xml.validation.SchemaFactory xsdSchemaFactory()
Returns a singleton SchemaFactory for .xsd schemas.


escapeContent

public static java.lang.String escapeContent(java.lang.String original)
Replaces reserved XML characters with entity references. The result is then safe to store as XML content.

Currently replaces the following:


escapeAttribute

public static java.lang.String escapeAttribute(java.lang.String original)
Replaces reserved XML characters with entity references. The result is then safe to store as an XML content attribute value.

Currently replaces the following:


stripTags

public static java.lang.String stripTags(java.lang.String original)
Removes all tags and returns remaining String contents.

Parameters:
original -
Returns:

unescape

public static java.lang.String unescape(java.lang.String original)
Replaces entity references for XML reserved characters with their character form. Reverses all the substitutions performed by escapeContent() and escapeAttribute().


validate

public static boolean validate(java.lang.String xml)
                        throws java.io.IOException
Validates the given XML string.

Throws:
java.io.IOException

validate

public static boolean validate(java.io.Reader reader)
                        throws java.io.IOException
Validates the given XML stream.

Throws:
java.io.IOException

validate

public static boolean validate(VfsFile file)
                        throws java.io.IOException
Validates the given XML file.

Throws:
java.io.IOException

validateAgainstSchema

public static boolean validateAgainstSchema(java.lang.String xml,
                                            VfsFile schemaFile)
                                     throws java.io.IOException
Validates the given XML string against a schema.

Throws:
java.io.IOException

validateAgainstSchema

public static boolean validateAgainstSchema(java.io.Reader reader,
                                            VfsFile schemaFile)
                                     throws java.io.IOException
Validates the given XML stream against its schema.

Throws:
java.io.IOException

validateAgainstSchema

public static boolean validateAgainstSchema(VfsFile file,
                                            VfsFile schemaFile)
                                     throws java.io.IOException
Validates the given XML file against a schema.

Throws:
java.io.IOException

validateAgainstSchemas

public static boolean validateAgainstSchemas(VfsFile file,
                                             VfsFile... schemaFiles)
                                      throws java.io.IOException
Validates the given XML file against a list of schemas.

Throws:
java.io.IOException