1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.util.xml;
16  
17  /**
18   * <a href="XMLConverter.java.html"><b><i>View Source</i></b></a>
19   *
20   * @author Brian Wing Shun Chan
21   */
22  public class XMLConverter {
23  
24      public static org.w3c.dom.Document toW3CDocument(
25              org.dom4j.Document dom4jDoc)
26          throws org.dom4j.DocumentException {
27  
28          org.dom4j.io.DOMWriter dom4jWriter = new org.dom4j.io.DOMWriter();
29  
30          org.w3c.dom.Document w3cDoc = dom4jWriter.write(dom4jDoc);
31  
32          return w3cDoc;
33      }
34  
35      public static org.w3c.dom.Element toW3CElement(org.dom4j.Element dom4jEl)
36          throws org.dom4j.DocumentException {
37  
38          org.dom4j.Document dom4jDoc =
39              org.dom4j.DocumentFactory.getInstance().createDocument();
40  
41          dom4jDoc.setRootElement(dom4jEl.createCopy());
42  
43          org.w3c.dom.Document w3cDoc = toW3CDocument(dom4jDoc);
44  
45          return w3cDoc.getDocumentElement();
46      }
47  
48      public static javax.xml.namespace.QName toJavaxQName(
49          org.dom4j.QName dom4jQName) {
50  
51          javax.xml.namespace.QName javaxQName = new javax.xml.namespace.QName(
52              dom4jQName.getNamespaceURI(), dom4jQName.getName(),
53              dom4jQName.getNamespacePrefix());
54  
55          return javaxQName;
56      }
57  
58  }