View Javadoc

1   /*$Id: XMLHelper.java,v 1.5 2004/11/22 18:26:54 clq2 Exp $
2    * Created on 12-Mar-2004
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid 
7    * Software License version 1.2, a copy of which has been included 
8    * with this distribution in the LICENSE.txt file.  
9    *
10  **/
11  package org.astrogrid.scripting;
12  
13  
14  import org.apache.axis.utils.XMLUtils;
15  import org.w3c.dom.Document;
16  import org.w3c.dom.Element;
17  import org.xml.sax.SAXException;
18  
19  import java.io.ByteArrayInputStream;
20  import java.io.IOException;
21  import java.io.InputStream;
22  
23  import javax.xml.parsers.ParserConfigurationException;
24  
25  /*** helper methods for working with xml.
26   * @author Noel Winstanley nw@jb.man.ac.uk 12-Mar-2004
27   *
28   */
29  public class XMLHelper {
30      /*** Construct a new XMLHelper
31       * 
32       */
33      public XMLHelper() {
34          super();
35      }
36  
37      /* convert an adql query to an Element
38       * @see org.astrogrid.datacenter.adql.ADQLUtils 
39      public Element toQueryBody(Select s) throws ADQLException {
40         return ADQLUtils.toQueryBody(s);
41      }*/
42      /*convert an sql string query to an Element
43       * @see org.astrogrid.datacenter.sql.SQLUtils 
44      public Element toQueryBody(String s) throws IOException {
45         return SQLUtils.toQueryBody(s);
46      }
47  */
48  
49  
50      // XML helper methods
51      /*** parse contents of input stream into document */
52      public Document newDocument(InputStream is) throws ParserConfigurationException, SAXException, IOException {
53         return XMLUtils.newDocument(is);
54      }
55      /*** parse contents of string into document */
56      public Document newDocument(String s) throws ParserConfigurationException, SAXException, IOException {
57         InputStream is = new ByteArrayInputStream(s.getBytes());
58         return XMLUtils.newDocument(is);
59      }
60      /*** create new DOM Document */
61      public Document newDocument() throws ParserConfigurationException {
62         return XMLUtils.newDocument();
63      }
64      /*** convert document to string */
65      public String documentToString(Document doc) {
66         return XMLUtils.DocumentToString(doc);
67      }
68      /*** convert element to string */
69      public String elementToString(Element el) {
70         return XMLUtils.ElementToString(el);
71      }
72      
73  }
74  
75  
76  /* 
77  $Log: XMLHelper.java,v $
78  Revision 1.5  2004/11/22 18:26:54  clq2
79  scripting-nww-715
80  
81  Revision 1.3.56.1  2004/11/22 15:54:51  nw
82  deprecated existing scripting interface (which includes service lists).
83  produced new scripting interface, with more helpler objects.
84  
85  Revision 1.3  2004/08/09 11:28:17  nw
86  improvied behaviour when no service list is found.
87  tidied imports.
88  
89  Revision 1.2  2004/03/14 23:11:32  nw
90  commented out code that used methods that have dissapeared from datacenter and applications delegate jars
91  
92  Revision 1.1  2004/03/12 13:50:23  nw
93  improved scripting object
94   
95  */