List of usage examples for com.google.gwt.xml.client Node getNamespaceURI
String getNamespaceURI();
From source file:com.bramosystems.oss.player.playlist.client.impl.SAXParser.java
License:Apache License
private void processNodes(NodeList node) throws ParseException { for (int i = 0; i < node.getLength(); i++) { Node nd = node.item(i); switch (nd.getNodeType()) { case Node.ELEMENT_NODE: HashMap<String, String> attr = new HashMap<String, String>(); NamedNodeMap nnm = nd.getAttributes(); for (int j = 0; j < nnm.getLength(); j++) { Node nm = nnm.item(j); attr.put(nm.getNodeName(), nm.getNodeValue()); }//from w ww . ja v a2s . co m handler.onNodeStart(nd.getNodeName(), attr, nd.getNamespaceURI()); processNodes(nd.getChildNodes()); handler.onNodeEnd(nd.getNodeName()); break; case Node.TEXT_NODE: handler.setNodeValue(nd.getParentNode().getNodeName(), nd.getNodeValue()); } } }
From source file:com.colinalworth.xmlview.client.schema.impl.AbstractSchemaImpl.java
License:Apache License
@Override public NamespacedNode createNode(Node node) { String[] nameParts = node.getNodeName().split(":"); return createNode(node.getNamespaceURI(), nameParts[nameParts.length - 1]); }
From source file:com.sensia.gwt.relaxNG.RNGParser.java
License:Open Source License
protected void parseChildren(RNGTag parent, Element parentElt) { NodeList children = parentElt.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (!(node instanceof Element)) continue; Element elt = (Element) node; String eltName = getLocalName(elt); String nsUri = node.getNamespaceURI(); // annotation if (nsUri != null && nsUri.equals(ANNOT_NS_URI) && eltName.equals("documentation")) parent.setAnnotation(getTextValue(node)); // parse nested relaxNG tags if (parent instanceof RNGTagList) { if (!nsUri.equals(RNG_NS_URI)) continue; RNGTag tag = null;/*w ww .j av a 2s.co m*/ if (eltName.equals("ref")) { RNGRef ref = new RNGRef(); ref.setParentGrammar(grammar); ref.setPatternName(elt.getAttribute("name")); parseChildren(ref, elt); tag = ref; } else if (eltName.equals("element")) { RNGElement rngElt = new RNGElement(); QName qname = parseRNGObjectName(elt); rngElt.setName(qname.localName); rngElt.setNamespace(qname.namespaceURI); parseChildren(rngElt, elt); tag = rngElt; } else if (eltName.equals("attribute")) { RNGAttribute rngAtt = new RNGAttribute(); QName qname = parseRNGObjectName(elt); rngAtt.setName(qname.localName); rngAtt.setNamespace(qname.namespaceURI); parseChildren(rngAtt, elt); tag = rngAtt; } else if (eltName.equals("optional")) { tag = new RNGOptional(); parseChildren(tag, elt); } else if (eltName.equals("choice")) { tag = new RNGChoice(); parseChildren(tag, elt); } else if (eltName.equals("zeroOrMore")) { tag = new RNGZeroOrMore(); parseChildren(tag, elt); } else if (eltName.equals("oneOrMore")) { tag = new RNGOneOrMore(); parseChildren(tag, elt); } else if (eltName.equals("group")) { tag = new RNGGroup(); parseChildren(tag, elt); } else if (eltName.equals("list")) { tag = new RNGList(); parseChildren(tag, elt); } else if (eltName.equals("text")) { tag = new RNGText(); parseChildren(tag, elt); } else if (eltName.equals("data")) { tag = parseDataType(elt); parseChildren(tag, elt); } else if (eltName.equals("value")) { RNGValue val = new RNGValue(); val.setText(getTextValue(elt)); parseChildren(val, elt); tag = val; } else if (eltName.equals("defaultValue")) { RNGValue val = new RNGValue(); val.setText(getTextValue(elt)); parseChildren(val, elt); tag = val; } if (tag != null) ((RNGTagList) parent).add(tag); } } }
From source file:com.sensia.gwt.relaxNG.RNGParser.java
License:Open Source License
protected void parsePatternsAndAddToGrammar(RNGGrammar grammar, Element parentElt) { NodeList children = parentElt.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (!(node instanceof Element)) continue; Element elt = (Element) node; String eltName = getLocalName(elt); String nsUri = node.getNamespaceURI(); if (!nsUri.equals(RNG_NS_URI)) continue; if (eltName.equals("define")) { RNGDefine pattern = new RNGDefine(); pattern.setId(elt.getAttribute("name")); parseChildren(pattern, elt); grammar.getPatterns().put(pattern.getId(), pattern); }/*from www . ja v a2 s. c o m*/ else if (eltName.equals("start")) { RNGGroup startPattern = new RNGGroup(); parseChildren(startPattern, elt); grammar.setStartPattern(startPattern); } } }
From source file:org.gwtcmis.unmarshallers.parser.AtomAuthorParser.java
License:Open Source License
/** * Parse xml document and return {@link AtomAuthor}. * /* w ww .j a v a 2 s . co m*/ * @param response response * @return {@link AtomAuthor} */ public static AtomAuthor parse(Node response) { AtomAuthor author = new AtomAuthor(); NodeList nodeList = response.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node item = nodeList.item(i); String nodeValue = item.getFirstChild().getNodeValue(); QName qName = new QName(item.getNodeName(), item.getNamespaceURI()); if (CMIS.ATOM_NAME.equals(qName)) { author.setName(nodeValue); } else if (CMIS.ATOM_EMAIL.equals(qName)) { author.setEmail(nodeValue); } else if (CMIS.ATOM_URI.equals(qName)) { author.setUri(nodeValue); } } return author; }
From source file:org.gwtcmis.unmarshallers.parser.AtomEntryParser.java
License:Open Source License
/** * Parse children node and set children entries to it's parent. * /*from w ww.ja v a 2 s. com*/ * @param parent parent * @param childrenNode children node */ private static void setChildren(AtomEntry parent, Node childrenNode) { if (childrenNode.getChildNodes() != null && childrenNode.getChildNodes().getLength() > 0) { for (int i = 0; i < childrenNode.getChildNodes().getLength(); i++) { if (childrenNode.getChildNodes().item(i).getNodeName().equals(CMIS.FEED)) { childrenNode = childrenNode.getChildNodes().item(i); } } // Go throw all nodes of feed to find entries (children of parent entry) for (int i = 0; i < childrenNode.getChildNodes().getLength(); i++) { Node node = childrenNode.getChildNodes().item(i); QName qName = new QName(node.getNodeName(), node.getNamespaceURI()); if (CMIS.ATOM_ENTRY.equals(qName)) { AtomEntry entry = new AtomEntry(); parse(node, entry); parent.getChildren().add(entry); } } } }
From source file:org.gwtcmis.unmarshallers.parser.AtomEntryParser.java
License:Open Source License
/** * @param nodeList node list/*from www .j a v a 2 s . c o m*/ * @return {@link EntryInfo} */ public static EntryInfo getEntryInfo(NodeList nodeList) { EntryInfo entryInfo = new EntryInfo(); int i = nodeList.getLength() - 1; //parse entry nodes to form entry info while ((i >= 0) && (nodeList.getLength() > 0)) { Node item = nodeList.item(i); String value = (item.getFirstChild() == null) ? "" : item.getFirstChild().getNodeValue(); QName qName = new QName(item.getNodeName(), item.getNamespaceURI()); if (CMIS.ATOM_AUTHOR.equals(qName)) { AtomAuthor author = AtomAuthorParser.parse(item); entryInfo.setAuthor(author); item.getParentNode().removeChild(item); } else if (CMIS.ATOM_CONTENT.equals(qName)) { AtomContentType content = new AtomContentType(); for (int k = 0; k < item.getAttributes().getLength(); k++) { if (item.getAttributes().item(k).getNodeName().equals(CMIS.SOURCE)) { content.setSource(item.getAttributes().item(k).getNodeValue()); } else if (item.getAttributes().item(k).getNodeName().equals(CMIS.TYPE)) { content.setType(item.getAttributes().item(k).getNodeValue()); } } entryInfo.setContent(content); item.getParentNode().removeChild(item); } else if (CMIS.ATOM_ID.equals(qName)) { entryInfo.setId(value); item.getParentNode().removeChild(item); } else if (CMIS.ATOM_SUMMARY.equals(qName)) { entryInfo.setSummary(value); item.getParentNode().removeChild(item); } else if (CMIS.ATOM_TITLE.equals(qName)) { entryInfo.setTitle(value); item.getParentNode().removeChild(item); } else if (CMIS.ATOM_UPDATED.equals(qName)) { entryInfo.setUpdated(DateUtil.parseDate(value)); item.getParentNode().removeChild(item); } else if (CMIS.ATOM_PUBLISHED.equals(qName)) { entryInfo.setPublished(DateUtil.parseDate(value)); item.getParentNode().removeChild(item); } else if (CMIS.ATOM_LINK.equals(qName)) { entryInfo.getLinks().add(AtomLinkParser.parse(item)); item.getParentNode().removeChild(item); } i--; } return entryInfo; }
From source file:org.gwtcmis.unmarshallers.parser.CollectionsParser.java
License:Open Source License
/** * Retrieve information about repositories collections from xml. * /*from w w w . j a v a 2s . com*/ * @param node node * @return List containing {@link CmisCollection} */ public static List<CmisCollection> parse(Node node) { List<CmisCollection> collections = new ArrayList<CmisCollection>(); for (int i = 0; i < node.getChildNodes().getLength(); i++) { Node collectionItem = node.getChildNodes().item(i); QName qName = new QName(collectionItem.getNodeName(), collectionItem.getNamespaceURI()); if (CMIS.COLLECTION.equals(qName)) { CmisCollection collection = new CmisCollection(); for (int j = 0; j < collectionItem.getAttributes().getLength(); j++) { Node attribute = collectionItem.getAttributes().item(j); if (attribute.getNodeName().equals(CMIS.HREF)) { collection.setHref(attribute.getNodeValue()); } } for (int j = 0; j < collectionItem.getChildNodes().getLength(); j++) { Node item = collectionItem.getChildNodes().item(j); if (item.getNodeName().equals(CMIS.CMISRA_COLLECTION_TYPE)) { collection.setType(EnumCollectionType.fromValue(item.getFirstChild().getNodeValue())); } } collections.add(collection); } } return collections; }
From source file:org.gwtcmis.unmarshallers.parser.FeedParser.java
License:Open Source License
/** * Parse xml feed to {@link FeedType}./*w w w. ja v a 2 s .c o m*/ * * @param response response * @return {@link FeedType} */ public static FeedType parse(Document response) { FeedType feed = new FeedType(); NodeList nodeList = response.getElementsByTagName(CMIS.FEED).item(0).getChildNodes(); FeedInfo feedInfo = getFeedInfo(nodeList); feed.setFeedInfo(feedInfo); for (int i = 0; i < nodeList.getLength(); i++) { Node item = nodeList.item(i); QName qName = new QName(item.getNodeName(), item.getNamespaceURI()); if (CMIS.ATOM_ENTRY.equals(qName)) { AtomEntry entry = new AtomEntry(); AtomEntryParser.parse(item, entry); feed.getEntries().add(entry); } } return feed; }
From source file:org.gwtcmis.unmarshallers.parser.FeedParser.java
License:Open Source License
/** * Parse feed info from xml to {@link FeedInfo}. * // ww w . j a v a 2 s . co m * @param nodeList node list * @return {@link FeedInfo} */ public static FeedInfo getFeedInfo(NodeList nodeList) { FeedInfo feedInfo = new FeedInfo(); // Go throw all feed nodes for (int i = 0; i < nodeList.getLength(); i++) { Node item = nodeList.item(i); QName qName = new QName(item.getNodeName(), item.getNamespaceURI()); if (CMIS.ATOM_TITLE.equals(qName)) { String nodeValue = (item.getFirstChild() != null) ? item.getFirstChild().getNodeValue() : ""; feedInfo.setTitle(nodeValue); } else if (CMIS.ATOM_UPDATED.equals(qName)) { String nodeValue = (item.getFirstChild() != null) ? item.getFirstChild().getNodeValue() : ""; feedInfo.setUpdated(DateUtil.parseDate(nodeValue)); } else if (CMIS.ATOM_PUBLISHED.equals(qName)) { String nodeValue = (item.getFirstChild() != null) ? item.getFirstChild().getNodeValue() : ""; feedInfo.setPublished(DateUtil.parseDate(nodeValue)); } else if (CMIS.ATOM_AUTHOR.equals(qName)) { AtomAuthor author = AtomAuthorParser.parse(item); feedInfo.setAuthor(author); } else if (CMIS.ATOM_ID.equals(qName)) { String nodeValue = (item.getFirstChild() != null) ? item.getFirstChild().getNodeValue() : ""; feedInfo.setId(nodeValue); } else if (item.getNodeName().equals(CMIS.APP_COLLECTION)) { AtomCollectionType collection = new AtomCollectionType(); NodeList collectionNodes = item.getChildNodes(); NamedNodeMap collectionAttributes = item.getAttributes(); String href = collectionAttributes.item(0).getFirstChild().getNodeValue(); collection.setHref(href); for (int j = 0; j < collectionNodes.getLength(); j++) { Node collectionNode = collectionNodes.item(j); if (collectionNode.getNodeName().equals(CMIS.ATOM_TITLE)) { String attribValue = collectionNode.getFirstChild().getNodeValue(); collection.setTittle(attribValue); } else if (collectionNode.getNodeName().equals(CMIS.APP_ACCEPT)) { String attribValue = collectionNode.getFirstChild().getNodeValue(); AtomAcceptType accept = new AtomAcceptType(); accept.setValue(attribValue); collection.getAccepts().add(accept); } } } else if (CMIS.ATOM_LINK.equals(qName)) { feedInfo.getLinks().add(AtomLinkParser.parse(item)); } } return feedInfo; }