1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.any23.validator;
19
20 import org.w3c.dom.Document;
21 import org.w3c.dom.Node;
22
23 import java.net.URI;
24 import java.util.List;
25
26 /**
27 * This interface models a document to be processed by the {@link Validator}.
28 *
29 * @author Michele Mostarda (mostarda@fbk.eu)
30 * @author Davide Palmisano (palmisano@fbk.eu)
31 */
32 public interface DOMDocument {
33
34 /**
35 * @return the original document IRI.
36 */
37 URI getDocumentIRI();
38
39 /**
40 * Returns the original document.
41 *
42 * @return the original document.
43 */
44 Document getOriginalDocument();
45
46 /**
47 * Returns the list of nodes addressed by the given <i>XPath</i>.
48 *
49 * @param xPath
50 * a valid XPath
51 *
52 * @return a not null list of nodes.
53 */
54 List<Node> getNodes(String xPath);
55
56 /**
57 * Returns the node addressed by the given <i>XPath</i>, if more then one an exception will be raised.
58 *
59 * @param xPath
60 * a valid XPath.
61 *
62 * @return a node or <code>null</code> if nothing found.
63 */
64 Node getNode(String xPath);
65
66 /**
67 * Adds an attribute to a node addressed by the given <i>XPath</i>.
68 *
69 * @param xPath
70 * the XPath pointing the node.
71 * @param attrName
72 * the name of the attribute.
73 * @param attrValue
74 * the value of the attribute.
75 */
76 void addAttribute(String xPath, String attrName, String attrValue);
77
78 /**
79 * Returns all the nodes declaring an attribute with the specified name.
80 *
81 * @param attrName
82 * name of attribute to use for filtering.
83 *
84 * @return a list of nodes. <i>null</i> if no matches found.
85 */
86 List<Node> getNodesWithAttribute(String attrName);
87 }