com.facetmap.format.xml
Class XmlFacetmapFactory

java.lang.Object
  extended by com.facetmap.format.xml.XmlFacetmapFactory

public class XmlFacetmapFactory
extends java.lang.Object

Produces a Facetmap object from a Facetmap XML document (see the Facetmap XML 2.0.1 DTD). Typically you'll use createFacetmapFromXml(InputStream, Properties) ; however, lower-level methods are available for parsing lower-level elements.

XFML support is disabled in this version but will return in the next version.

This is, at present, a stateful factory object; it holds the state of the Facetmap it's generating. This, along with its unsightly multitude of public methods, allows it to be used by more complex Facetmap creation software. But as a result you should construct one XmlFacetmapFactory for each Facetmap you intend to produce.

In other words, this class is neither stateless nor threadsafe.

Some arcane specifics about this: All methods here use an instance variable for the Document. So, use of those routines must be synchronized so two threads don't use the same Document. (This shouldn't be a problem, since every thread should be constructing its own XmlFacetmapFactory.) Methods that create Document objects should synchronize on this XmlFacetmapFactory object. Methods that build Elements should not be synchronized, but they should only be called by other Element-builders and the synchronized Document-builders. That's why they're protected.


Field Summary
protected  java.text.DateFormat dateFormat
           
protected  org.w3c.dom.Document doc
           
static java.util.Hashtable DOCTYPE_TRANSFORMERS
           
static java.util.Hashtable ELEMENT_TRANSFORMERS
           
protected  SimpleFacetmap facetmap
           
protected  SimpleFacetSpace facetSpace
           
protected  XmlResourceParser rParser
           
protected  java.text.DateFormat timeFormat
           
protected  java.io.File workDir
           
 
Constructor Summary
XmlFacetmapFactory()
           
XmlFacetmapFactory(java.net.URL docsUrl, java.io.File workDir)
           
 
Method Summary
protected  void addChildren(org.w3c.dom.Node parent, SimpleTaxonomyHeading parentHeading, SimpleTaxonomyFacet tax)
           
static java.util.Hashtable createDoctypeTransformers()
           
 DOMParser createDOMParser()
           
static java.util.Hashtable createElementTransformers()
           
 SimpleFacetmap createFacetmap(java.lang.String title)
           
 Facetmap createFacetmapFromXml(java.io.InputStream inputStream, java.util.Properties props)
           
 SimpleSpectrumFacet loadSpectrum(java.lang.String url, java.lang.String id)
           
 SimpleTaxonomyFacet loadTaxonomy(java.lang.String url, java.lang.String id)
           
static void main(java.lang.String[] argv)
          Parses XML provided to standard input, and writes equivalent Facetmap XML to standard out.
 Facetmap parse(java.io.BufferedReader r)
          Construct a Facetmap object using all the default properties.
 Facetmap parse(java.io.BufferedReader r, java.util.Properties props)
           
 Facetmap parse(java.lang.String systemId)
          I think the latest xerces code can find a xml doc in a few places given a systemId.
 java.util.Date parseDateAttribute(java.lang.String attributeValue)
           
 SimpleDateFacet parseDateFacet(org.w3c.dom.Element dElem)
           
 void parseFacetmap(org.w3c.dom.Element fmElem)
           
 void parseOnlyResources(org.w3c.dom.Element resources)
           
 SpectrumHeading parseRange(org.w3c.dom.Element rElem, SimpleSpectrumFacet spect)
          This parser also adds the range to the spectrum (since that's required to create the range).
 SimpleSpectrumFacet parseSpectrum(org.w3c.dom.Element spectrumElem)
           
 SimpleSpectrumFacet parseSpectrum(org.w3c.dom.Element sElem, java.lang.String id)
           
 TaxonomyFacet parseTaxonomy(org.w3c.dom.Element taxonomyElem)
           
 SimpleTaxonomyFacet parseTaxonomy(org.w3c.dom.Element taxonomyElem, java.lang.String id)
           
 UnfacetedResource.UnfacetedHeading parseUnfacetedHeading(org.w3c.dom.Element mapElem)
           
 UnfacetedResource parseUnfacetedResource(org.w3c.dom.Element resourceElem)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOCTYPE_TRANSFORMERS

public static java.util.Hashtable DOCTYPE_TRANSFORMERS

ELEMENT_TRANSFORMERS

public static java.util.Hashtable ELEMENT_TRANSFORMERS

facetmap

protected SimpleFacetmap facetmap

facetSpace

protected SimpleFacetSpace facetSpace

workDir

protected java.io.File workDir

rParser

protected XmlResourceParser rParser

dateFormat

protected java.text.DateFormat dateFormat

timeFormat

protected java.text.DateFormat timeFormat

doc

protected org.w3c.dom.Document doc
Constructor Detail

XmlFacetmapFactory

public XmlFacetmapFactory()

XmlFacetmapFactory

public XmlFacetmapFactory(java.net.URL docsUrl,
                          java.io.File workDir)
Method Detail

createFacetmap

public SimpleFacetmap createFacetmap(java.lang.String title)
                              throws DataException
Throws:
DataException

createDoctypeTransformers

public static java.util.Hashtable createDoctypeTransformers()

createElementTransformers

public static java.util.Hashtable createElementTransformers()

createDOMParser

public DOMParser createDOMParser()
                          throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

parseTaxonomy

public TaxonomyFacet parseTaxonomy(org.w3c.dom.Element taxonomyElem)
                            throws java.io.IOException,
                                   DataException
Throws:
java.io.IOException
DataException

parseTaxonomy

public SimpleTaxonomyFacet parseTaxonomy(org.w3c.dom.Element taxonomyElem,
                                         java.lang.String id)
                                  throws java.io.IOException,
                                         DataException
Throws:
java.io.IOException
DataException

loadTaxonomy

public SimpleTaxonomyFacet loadTaxonomy(java.lang.String url,
                                        java.lang.String id)
                                 throws java.io.IOException,
                                        DataException
Throws:
java.io.IOException
DataException

parseSpectrum

public SimpleSpectrumFacet parseSpectrum(org.w3c.dom.Element spectrumElem)
                                  throws java.io.IOException,
                                         DataException
Throws:
java.io.IOException
DataException

parseDateFacet

public SimpleDateFacet parseDateFacet(org.w3c.dom.Element dElem)
                               throws DataException
Throws:
DataException

parseDateAttribute

public java.util.Date parseDateAttribute(java.lang.String attributeValue)
                                  throws DataException
Throws:
DataException

parseSpectrum

public SimpleSpectrumFacet parseSpectrum(org.w3c.dom.Element sElem,
                                         java.lang.String id)
                                  throws java.io.IOException,
                                         DataException
Throws:
java.io.IOException
DataException

loadSpectrum

public SimpleSpectrumFacet loadSpectrum(java.lang.String url,
                                        java.lang.String id)
                                 throws java.io.IOException,
                                        DataException
Throws:
java.io.IOException
DataException

parseRange

public SpectrumHeading parseRange(org.w3c.dom.Element rElem,
                                  SimpleSpectrumFacet spect)
                           throws DataException
This parser also adds the range to the spectrum (since that's required to create the range).

Throws:
DataException

parse

public Facetmap parse(java.io.BufferedReader r)
               throws java.io.IOException,
                      DataException,
                      InternalException
Construct a Facetmap object using all the default properties.

Throws:
java.io.IOException
DataException
InternalException

parse

public Facetmap parse(java.io.BufferedReader r,
                      java.util.Properties props)
               throws java.io.IOException,
                      DataException,
                      InternalException
Throws:
java.io.IOException
DataException
InternalException

createFacetmapFromXml

public Facetmap createFacetmapFromXml(java.io.InputStream inputStream,
                                      java.util.Properties props)
                               throws java.io.IOException,
                                      DataException,
                                      InternalException
Throws:
java.io.IOException
DataException
InternalException

parse

public Facetmap parse(java.lang.String systemId)
               throws java.io.IOException,
                      DataException,
                      InternalException
I think the latest xerces code can find a xml doc in a few places given a systemId. For now I'm just going to assume the systemId represents a filename (one of the systemId possibilities, I think).

Throws:
java.io.IOException
DataException
InternalException

parseOnlyResources

public void parseOnlyResources(org.w3c.dom.Element resources)

parseUnfacetedResource

public UnfacetedResource parseUnfacetedResource(org.w3c.dom.Element resourceElem)

parseUnfacetedHeading

public UnfacetedResource.UnfacetedHeading parseUnfacetedHeading(org.w3c.dom.Element mapElem)

parseFacetmap

public void parseFacetmap(org.w3c.dom.Element fmElem)
                   throws java.io.IOException,
                          DataException,
                          InternalException
Throws:
java.io.IOException
DataException
InternalException

addChildren

protected void addChildren(org.w3c.dom.Node parent,
                           SimpleTaxonomyHeading parentHeading,
                           SimpleTaxonomyFacet tax)
                    throws DataException
Throws:
DataException

main

public static void main(java.lang.String[] argv)
                 throws DataException,
                        InternalException,
                        java.io.IOException
Parses XML provided to standard input, and writes equivalent Facetmap XML to standard out. This can be used to validate or normalize Facetmap XML. Facetmap properties can be specified in the system properties, but at the time of this writing, no properties are used in XmlFacetmapFactory.

java -Dcom.facetmap.licenseFile=./license.txt -Dcom.facetmap.sourceTable.column.Name=title com.facetmap.format.excel.ExcelFacetmapFactory records.xls > record-facetmap.xml

Throws:
DataException
InternalException
java.io.IOException