| XMLConverter.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
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 }