Changeset 6232


Ignore:
Timestamp:
05/05/10 10:30:52 (10 years ago)
Author:
melissa
Message:

OME-XML generation should work now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/ome/AbstractOMEXMLMetadata.java

    r6230 r6232  
    2727import java.util.Hashtable; 
    2828 
     29import javax.xml.parsers.DocumentBuilder; 
     30import javax.xml.parsers.DocumentBuilderFactory; 
     31import javax.xml.parsers.ParserConfigurationException; 
    2932import javax.xml.transform.TransformerException; 
    3033 
    3134import ome.xml.DOMUtil; 
    32 import ome.xml.OMEXMLNode; 
     35import ome.xml.r201004.OMEModelObject; 
    3336 
    34 import org.w3c.dom.Attr; 
     37import org.w3c.dom.Document; 
    3538import org.w3c.dom.Element; 
    36 import org.w3c.dom.NamedNodeMap; 
    37 import org.w3c.dom.Node; 
    38 import org.w3c.dom.NodeList; 
    3939 
    4040/** 
     
    6060 
    6161  /** The root element of OME-XML. */ 
    62   protected OMEXMLNode root; 
     62  protected OMEModelObject root; 
    6363 
    6464  /** DOM element that backs the first Image's CustomAttributes node. */ 
     
    7171  private Hashtable<String, String> originalMetadata; 
    7272 
     73  private DocumentBuilder builder; 
     74 
    7375  // -- Constructors -- 
    7476 
    7577  /** Creates a new OME-XML metadata object. */ 
    76   public AbstractOMEXMLMetadata() { } 
     78  public AbstractOMEXMLMetadata() { 
     79    try { 
     80      builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); 
     81    } 
     82    catch (ParserConfigurationException e) { } 
     83  } 
    7784 
    7885  // -- OMEXMLMetadata API methods -- 
     
    8390   */ 
    8491  public String dumpXML() { 
    85     if (root == null) return null; 
     92    if (root == null) { 
     93      root = (OMEModelObject) getRoot(); 
     94      if (root == null) return null; 
     95    } 
    8696    try { 
    8797      ByteArrayOutputStream os = new ByteArrayOutputStream(); 
    88       DOMUtil.writeXML(os, root.getDOMElement().getOwnerDocument()); 
     98      Document doc = builder.newDocument(); 
     99      Element r = root.asXMLElement(doc); 
     100      doc.appendChild(r); 
     101      DOMUtil.writeXML(os, doc); 
    89102      return os.toString(); 
    90103    } 
     
    116129  /* @see loci.formats.meta.MetadataRetrieve#getUUID() */ 
    117130  public String getUUID() { 
    118     Element ome = root.getDOMElement(); 
     131    Element ome = root.asXMLElement(builder.newDocument()); 
    119132    return DOMUtil.getAttribute("UUID", ome); 
    120133  } 
     
    134147  /* @see loci.formats.meta.MetadataRetrieve#setUUID(String) */ 
    135148  public void setUUID(String uuid) { 
    136     Element ome = root.getDOMElement(); 
     149    Element ome = root.asXMLElement(builder.newDocument()); 
    137150    DOMUtil.setAttribute("UUID", uuid, ome); 
    138151  } 
Note: See TracChangeset for help on using the changeset viewer.