001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.xml;
016    
017    import java.io.File;
018    import java.io.InputStream;
019    import java.io.Reader;
020    
021    import java.net.MalformedURLException;
022    import java.net.URL;
023    
024    import java.util.List;
025    import java.util.Map;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public interface SAXReader {
031    
032            public Attribute createAttribute(
033                    Element element, QName qName, String value);
034    
035            public Attribute createAttribute(
036                    Element element, String name, String value);
037    
038            public Document createDocument();
039    
040            public Document createDocument(Element rootElement);
041    
042            public Document createDocument(String encoding);
043    
044            public Element createElement(QName qName);
045    
046            public Element createElement(String name);
047    
048            public Entity createEntity(String name, String text);
049    
050            public Namespace createNamespace(String uri);
051    
052            public Namespace createNamespace(String prefix, String uri);
053    
054            public ProcessingInstruction createProcessingInstruction(
055                    String target, Map<String, String> data);
056    
057            public ProcessingInstruction createProcessingInstruction(
058                    String target, String data);
059    
060            public QName createQName(String localName);
061    
062            public QName createQName(String localName, Namespace namespace);
063    
064            public Text createText(String text);
065    
066            public XPath createXPath(String xPathExpression);
067    
068            public XPath createXPath(
069                    String xPathExpression, Map<String, String> namespaceContextMap);
070    
071            public XPath createXPath(
072                    String xPathExpression, String prefix, String namespace);
073    
074            public Document read(File file) throws DocumentException;
075    
076            public Document read(File file, boolean validate)
077                    throws DocumentException;
078    
079            public Document read(InputStream is) throws DocumentException;
080    
081            public Document read(InputStream is, boolean validate)
082                    throws DocumentException;
083    
084            public Document read(Reader reader) throws DocumentException;
085    
086            public Document read(Reader reader, boolean validate)
087                    throws DocumentException;
088    
089            public Document read(String xml) throws DocumentException;
090    
091            public Document read(String xml, boolean validate)
092                    throws DocumentException;
093    
094            public Document read(URL url) throws DocumentException;
095    
096            public Document read(URL url, boolean validate) throws DocumentException;
097    
098            public Document readURL(String url)
099                    throws DocumentException, MalformedURLException;
100    
101            public Document readURL(String url, boolean validate)
102                    throws DocumentException, MalformedURLException;
103    
104            public List<Node> selectNodes(
105                    String xPathFilterExpression, List<Node> nodes);
106    
107            public List<Node> selectNodes(String xPathFilterExpression, Node node);
108    
109            public void sort(List<Node> nodes, String xPathExpression);
110    
111            public void sort(
112                    List<Node> nodes, String xPathExpression, boolean distinct);
113    
114    }