private static void addNoSchemaAttributes(XmlObject elem, List attrList) { XmlCursor cursor = elem.newCursor(); boolean hasAttributes = cursor.toFirstAttribute(); while (hasAttributes) { QName name = cursor.getName(); String namespaceURI = name.getNamespaceURI(); if ("".equals(namespaceURI) || "http://www.w3.org/2001/XMLSchema".equals(namespaceURI)) ; // no nothing else { String attValue = cursor.getTextValue(); String valUri; String prefix; if (attValue.indexOf(':') > 0) prefix = attValue.substring(0, attValue.indexOf(':')); else prefix = ""; cursor.push(); cursor.toParent(); valUri = cursor.namespaceForPrefix(prefix); cursor.pop(); attrList.add(new AttributeImpl(name, attValue, valUri)); //add the attribute } hasAttributes = cursor.toNextAttribute(); } cursor.dispose(); }
/** * Selects the content of the attribute with the given name. */ public XmlObject selectAttribute(QName attributeName) { XmlCursor xc = this.newCursor(); try { if (!xc.isContainer()) return null; if (xc.toFirstAttribute()) { //look for attributes do { if (xc.getName().equals(attributeName)) { return xc.getObject(); } } while (xc.toNextAttribute()); } return null; } finally { xc.dispose(); } }
c.toFirstAttribute(); // on the "foo" attribute c.push(); System.out.println(generateXPath(c, d, ns)); c.pop(); c.toParent();
private boolean verify_condition(XmlCursor cursor, Condition condition) { boolean more, found=false; XmlBookmark bookmark = new XmlBookmark(){}; cursor.setBookmark(bookmark); if (condition.isAttribute) { for (more=cursor.toFirstAttribute(); more&&!found; more=cursor.toNextAttribute()) { if (cursor.getName().getLocalPart().equals(condition.name)) { found = cursor.getTextValue().trim().equals(condition.value); } } } else { for (more=cursor.toFirstChild(); more&&!found; more=cursor.toNextSibling()) { if (cursor.getName().getLocalPart().equals(condition.name)) { found = cursor.getTextValue().trim().equals(condition.value); } } } cursor.toBookmark(bookmark); return found; }
public DDBeanImpl(DDBeanRoot root, DDBean parent, String xpath, XmlCursor c) { this.root = root; this.parent = parent; this.xpath = xpath; this.children = new HashMap(); this.attributeMap = new HashMap(); content = c.getTextValue(); c.push(); if (c.toFirstAttribute()) { do { attributeMap.put(c.getName().getLocalPart(), c.getTextValue()); } while (c.toNextAttribute()); } c.pop(); c.push(); if (c.toFirstChild()) { do { String name = c.getName().getLocalPart(); List nodes = (List) children.get(name); if (nodes == null) { nodes = new ArrayList(); children.put(name, nodes); } nodes.add(new DDBeanImpl(root, this, xpath + "/" + name, c)); } while (c.toNextSibling()); } c.pop(); }
public static int getActivityWorkflowTimestep(XmlObject activity) { // $ACTIVITY_XML/*/notificationSource/@workflowTimestep XmlCursor xc = activity.newCursor(); // ./ // xc.toStartDoc(); // ./* xc.toNextToken(); // ./*/notificationSource xc.toChild(NOTIFICATION_SRC_QNAME); // ./*/notificationSource/@* boolean hasAttr = xc.toFirstAttribute(); while (hasAttr && !WF_TIMESTEP_QNAME.equals(xc.getName())) { hasAttr = xc.toNextAttribute(); } if (hasAttr) { // ./*/notificationSource/@workflowTimestep return Integer.parseInt(xc.getTextValue()); } else { return -1; } }
private static void addNoSchemaAttributes(XmlObject elem, List attrList) { XmlCursor cursor = elem.newCursor(); boolean hasAttributes = cursor.toFirstAttribute(); while (hasAttributes) { QName name = cursor.getName(); String namespaceURI = name.getNamespaceURI(); if ("".equals(namespaceURI) || "http://www.w3.org/2001/XMLSchema".equals(namespaceURI)) ; // no nothing else { String attValue = cursor.getTextValue(); String valUri; String prefix; if (attValue.indexOf(':') > 0) prefix = attValue.substring(0, attValue.indexOf(':')); else prefix = ""; cursor.push(); cursor.toParent(); valUri = cursor.namespaceForPrefix(prefix); cursor.pop(); attrList.add(new AttributeImpl(name, attValue, valUri)); //add the attribute } hasAttributes = cursor.toNextAttribute(); } cursor.dispose(); }
private static void addNoSchemaAttributes(XmlObject elem, List attrList) { XmlCursor cursor = elem.newCursor(); boolean hasAttributes = cursor.toFirstAttribute(); while (hasAttributes) { QName name = cursor.getName(); String namespaceURI = name.getNamespaceURI(); if ("".equals(namespaceURI) || "http://www.w3.org/2001/XMLSchema".equals(namespaceURI)) ; // no nothing else { String attValue = cursor.getTextValue(); String valUri; String prefix; if (attValue.indexOf(':') > 0) prefix = attValue.substring(0, attValue.indexOf(':')); else prefix = ""; cursor.push(); cursor.toParent(); valUri = cursor.namespaceForPrefix(prefix); cursor.pop(); attrList.add(new AttributeImpl(name, attValue, valUri)); //add the attribute } hasAttributes = cursor.toNextAttribute(); } cursor.dispose(); }
/** * Selects the content of the attribute with the given name. */ public XmlObject selectAttribute(QName attributeName) { XmlCursor xc = this.newCursor(); try { if (!xc.isContainer()) return null; if (xc.toFirstAttribute()) { //look for attributes do { if (xc.getName().equals(attributeName)) { return xc.getObject(); } } while (xc.toNextAttribute()); } return null; } finally { xc.dispose(); } }
/** * Selects the content of the attribute with the given name. */ public XmlObject selectAttribute(QName attributeName) { XmlCursor xc = this.newCursor(); try { if (!xc.isContainer()) return null; if (xc.toFirstAttribute()) { //look for attributes do { if (xc.getName().equals(attributeName)) { return xc.getObject(); } } while (xc.toNextAttribute()); } return null; } finally { xc.dispose(); } }
XmlBookmark bookmark = new XmlBookmark(){}; cursor.setBookmark(bookmark); boolean more = cursor.toFirstAttribute(); while (value==null && more) { if (cursor.getName().getLocalPart().equals(path.name) || path.name.equals("*")) {
public static void clearElement(final XmlObject object) { final XmlCursor cursor = object.newCursor(); cursor.removeXmlContents(); final XmlCursor start = object.newCursor(); while (cursor.toFirstAttribute()) { cursor.removeXml(); cursor.toCursor(start); } start.dispose(); cursor.dispose(); }
boolean hasNext = cursor.toFirstAttribute(); while(hasNext)
if (curs.toFirstAttribute())
c.toFirstAttribute(); // on the "foo" attribute c.push(); System.out.println(generateXPath(c, d, ns)); c.pop(); c.toParent();
c.toFirstAttribute(); // on the "foo" attribute c.push(); System.out.println(generateXPath(c, d, ns)); c.pop(); c.toParent();
/** * * @param name * @return */ private XMLList matchAttributes(XMLName xmlName) { XMLList result = new XMLList(lib); XmlCursor curs = newCursor(); if (curs.currentTokenType().isStartdoc()) { curs.toFirstContentToken(); } if (curs.isStart()) { if (curs.toFirstAttribute()) { do { if (qnameMatches(xmlName, curs.getName())) { result.addToList(createAttributeObject(curs)); } } while (curs.toNextAttribute()); } } curs.dispose(); return result; }