Class XMLParser
java.lang.Object
br.ufsc.labsec.utils.XMLParser
Classe auxiliar para tratar utilidades comuns
a documentos XML
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncollectAttributesToResolve(List<String> attrs, NodeList targetNode) Coleta os atributos requisitados de uma nodelist alvostatic DocumentcreateDocument(InputStream inputStream) getChildElements(Node rootElement, String namespace, String elementName) static ElementgetElementOrCreate(Element rootElement, String elementName, String namespace, Document baseDoc) getElements(Node rootElement, String namespace, String elementName) getElementsChildren(NodeList nodeList) Responsável por tratar de todos os filhos e pegar apenas os nodos realmente (removendo elementos em branco, por exemplo)static ElementgetFirstChildElement(Element element) Responsável por pegar o primeiro filho que seja um elementostatic ElementgetFirstChildElement(NodeList nodeList) getIdElement(Node node) Responsável por pegar o "Id" de determinado elemento.static intgetIndexSibling(Node node) Pega o índice de determinado nodostatic ElementgetLastChildElement(Element element) Responsável por pegar o último filho que seja um elementostatic ElementgetLastChildElement(NodeList children) static DocumentInstancia um novoDocument, que será usado para escrever a assinatura.static NodegetNodeFromXPath(Document document, String xpath) static NodegetNodeFromXPath(Node node, String path) static NodeListgetNodeListFromXPath(Node node, String path) static NodeListgetNodesFromXPath(Node node, String path) static ElementgetNthChildElement(Element element, int nth) Responsável por pegar o nth filho que seja um elementostatic ElementgetNthChildElement(NodeList children, int nth) Responsável por pegar o nth filho que seja um elementostatic ElementgetSecondChildElement(Element element) Responsável por pegar o segundo filho que seja um elementostatic Stringstatic StringDetermina o XPath completo a partir de um elementostatic booleanstatic StringresolveNamespace(String path) wrapNodeList(NodeList nodeList) wrapNodeList(NodeList nodeList, Class<T> clazz)
-
Field Details
-
SCHEMA
Schema para verificação de assinaturas -
TL_SCHEMA
Schema para verificação de listas confiáveis -
QUALIFYING_PROPERTIES
- See Also:
-
-
Constructor Details
-
XMLParser
public XMLParser()
-
-
Method Details
-
getElementsChildren
-
getFirstChildElement
-
getLastChildElement
-
wrapNodeList
-
wrapNodeList
-
getFirstChildElement
-
getSecondChildElement
-
getNthChildElement
-
getNthChildElement
-
getLastChildElement
-
getIdElement
Responsável por pegar o "Id" de determinado elemento. Esse método é necessário, pois ocorrem vários equívocos ao fazer tal atributo- Parameters:
node- Elemento que deseja pegar o identificador ("Id")- Returns:
- Nome do atributo e valor do atributo de identificador
-
getIndexSibling
Pega o índice de determinado nodo- Parameters:
node- Nodo que deseja pegar o índice- Returns:
- Índice do nodo dado
-
getXPath
-
getXPath
-
getNewDocument
Instancia um novoDocument, que será usado para escrever a assinatura.- Returns:
- O objeto gerado
- Throws:
ParserConfigurationException- Exceção em caso de erro na geração do documento
-
createDocument
public static Document createDocument(InputStream inputStream) throws ParserConfigurationException, IOException, SAXException -
getNodeFromXPath
public static Node getNodeFromXPath(Document document, @Language("XPath") String xpath) throws XPathExpressionException - Throws:
XPathExpressionException
-
getNodeFromXPath
public static Node getNodeFromXPath(Node node, @Language("XPath") String path) throws XPathExpressionException - Throws:
XPathExpressionException
-
getNodeListFromXPath
public static NodeList getNodeListFromXPath(Node node, @Language("XPath") String path) throws XPathExpressionException - Throws:
XPathExpressionException
-
getNodesFromXPath
- Throws:
XPathExpressionException
-
resolveNamespace
-
collectAttributesToResolve
public static List<String> collectAttributesToResolve(List<String> attrs, NodeList targetNode) throws PbadException Coleta os atributos requisitados de uma nodelist alvo- Parameters:
attrs- os atributos a serem buscadostargetNode- o nodo que deve conter os atributos- Returns:
- lista dos nodos encontrados
- Throws:
PbadException
-
getElementOrCreate
-
getChildElements
-
isChildOf
-
getElements
-