001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.util.xml;
016    
017    /**
018     * @author Brian Wing Shun Chan
019     */
020    public class XMLConverter {
021    
022            public static org.w3c.dom.Document toW3CDocument(
023                            org.dom4j.Document dom4jDoc)
024                    throws org.dom4j.DocumentException {
025    
026                    org.dom4j.io.DOMWriter dom4jWriter = new org.dom4j.io.DOMWriter();
027    
028                    org.w3c.dom.Document w3cDoc = dom4jWriter.write(dom4jDoc);
029    
030                    return w3cDoc;
031            }
032    
033            public static org.w3c.dom.Element toW3CElement(org.dom4j.Element dom4jEl)
034                    throws org.dom4j.DocumentException {
035    
036                    org.dom4j.Document dom4jDoc =
037                            org.dom4j.DocumentFactory.getInstance().createDocument();
038    
039                    dom4jDoc.setRootElement(dom4jEl.createCopy());
040    
041                    org.w3c.dom.Document w3cDoc = toW3CDocument(dom4jDoc);
042    
043                    return w3cDoc.getDocumentElement();
044            }
045    
046            public static javax.xml.namespace.QName toJavaxQName(
047                    org.dom4j.QName dom4jQName) {
048    
049                    javax.xml.namespace.QName javaxQName = new javax.xml.namespace.QName(
050                            dom4jQName.getNamespaceURI(), dom4jQName.getName(),
051                            dom4jQName.getNamespacePrefix());
052    
053                    return javaxQName;
054            }
055    
056    }