TokenType t = cursor.toNextToken(); if (t.isText()) { sb.append(cursor.getTextValue()); } else if (isStartToken(cursor, "tr")) { tcCnt = 0;
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(); }
public void processDoc(XmlObject[] instances, Inst2XsdOptions options, TypeSystemHolder typeSystemHolder) { for (int i = 0; i < instances.length; i++) { XmlObject instance = instances[i]; XmlCursor xc = instance.newCursor(); // xc on start doc StringBuffer comment = new StringBuffer(); while( !xc.isStart() ) { xc.toNextToken(); if( xc.isComment() ) comment.append(xc.getTextValue()); else if (xc.isEnddoc()) return; } // xc now on the root element Element withElem = processElement(xc, comment.toString(), options, typeSystemHolder); withElem.setGlobal(true); addGlobalElement(withElem, typeSystemHolder, options); } }
commentBuff.append(xc.getTextValue()); break;
protected Attribute processAttribute(XmlCursor xc, Inst2XsdOptions options, String parentNamespace, TypeSystemHolder typeSystemHolder) { assert xc.isAttr() : "xc not on attribute"; Attribute attribute = new Attribute(); QName attName = xc.getName(); attribute.setName(attName); XmlCursor parent = xc.newCursor(); parent.toParent(); Type simpleContentType = Type.createNamedType( processSimpleContentType(xc.getTextValue(), options, parent), Type.SIMPLE_TYPE_SIMPLE_CONTENT); parent.dispose(); attribute.setType(simpleContentType); checkIfAttributeReferenceIsNeeded(attribute, parentNamespace, typeSystemHolder); return attribute; }
/** * * @param xmlOne * @param xmlTwo * @return */ private static boolean commentsEqual(XmlCursor xmlOne, XmlCursor xmlTwo) { boolean result = false; if (xmlOne.isComment() && xmlTwo.isComment()) { if (xmlOne.getTextValue().equals(xmlTwo.getTextValue())) { result = true; } } return result; }
public static String getRootNodeValue(XmlObject xmlbean) { XmlCursor cursor = xmlbean.newCursor(); cursor.toFirstChild(); return cursor.getTextValue(); }
private void cleanContextPriorityClassLoader(XmlCursor cursor) { String localName = getLocalName(cursor); if ("context-priority-classloader".equals(localName)) { String value = cursor.getTextValue(); if ("false".equals(value)) { cursor.removeXml(); } else if ("true".equals("true")) { cursor.removeXml(); cursor.insertComment("YOU MUST INSERT THE ELEMENT <inverse-classloading/> INTO THE ENVIRONMENT ELEMENT FOR THIS MODULE"); } } }
private static ObjectName extractObjectName(XmlCursor cursor) throws XmlException { String targetNameString = cursor.getTextValue(); cursor.removeXml(); ObjectName targetName; try { targetName = ObjectName.getInstance(targetNameString); } catch (MalformedObjectNameException e) { throw (XmlException)new XmlException("Invalid object name: " + targetNameString).initCause(e); } return targetName; }
/** * * @param xml * @return */ private static TreeMap loadAttributeMap(XmlCursor xml) { TreeMap result = new TreeMap(); while (xml.isAttr()) { result.put(xml.getTextValue(), xml.getName()); nextToken(xml); } return result; }
private String resolveSubscriptionResource(XmlObject response) { for (ResourceIdInstance rid : RESOURCE_ID_INSTANCES) { XmlObject[] resourceObj = XmlUtil.selectPath(rid.getXPathExpression(), response); if (resourceObj != null && resourceObj.length > 0) { this.resourceIdInstance = rid; return resourceObj[0].newCursor().getTextValue().trim(); } } return null; }
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; }
/** * * @param xmlOne * @param xmlTwo * @return */ private static boolean processingInstructionsEqual(XmlCursor xmlOne, XmlCursor xmlTwo) { boolean result = false; if (xmlOne.isProcinst() && xmlTwo.isProcinst()) { if (qnamesEqual(xmlOne.getName(), xmlTwo.getName())) { if (xmlOne.getTextValue().equals(xmlTwo.getTextValue())) { result = true; } } } return result; }
/** * * @param xmlOne * @param xmlTwo * @return */ private static boolean attributesEqual(XmlCursor xmlOne, XmlCursor xmlTwo) { boolean result = false; if (xmlOne.isAttr() && xmlTwo.isAttr()) { if (qnamesEqual(xmlOne.getName(), xmlTwo.getName())) { if (xmlOne.getTextValue().equals(xmlTwo.getTextValue())) { result = true; } } } return result; }
private String getTextContent(final XmlObject pValue) { if (pValue == null) { return ""; } String lRes = ""; XmlCursor lCursor = pValue.newCursor(); lCursor.toFirstContentToken(); if (lCursor.isText()) { lRes = lCursor.getTextValue(); } lCursor.dispose(); return lRes; }
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; } }
public static Date getActivityTimestamp(XmlObject activity) throws ParseException { // $ACTIVITY_XML/*/timestamp XmlCursor xc = activity.newCursor(); // ./ // xc.toStartDoc(); // ./* xc.toNextToken(); // ./*/timestamp xc.toChild(TIMESTAMP_QNAME); System.out.println(xc.xmlText()); XmlCalendar calendar = new XmlCalendar(xc.getTextValue()); // return getDateFormat().parse(xc.getTextValue()); // fixme: this // supports only one date format return calendar.getTime(); }
/** * * @param cursor * @param opts * @return */ private static String dumpNode(XmlCursor cursor, XmlOptions opts) { if (cursor.isText()) return cursor.getChars(); if (cursor.isFinish()) return ""; cursor.push(); boolean wanRawText = cursor.isStartdoc() && !cursor.toFirstChild(); cursor.pop(); return wanRawText ? cursor.getTextValue() : cursor.xmlText( opts ); }
protected Attribute processAttribute(XmlCursor xc, Inst2XsdOptions options, String parentNamespace, TypeSystemHolder typeSystemHolder) { assert xc.isAttr() : "xc not on attribute"; Attribute attribute = new Attribute(); QName attName = xc.getName(); attribute.setName(attName); XmlCursor parent = xc.newCursor(); parent.toParent(); Type simpleContentType = Type.createNamedType( processSimpleContentType(xc.getTextValue(), options, parent), Type.SIMPLE_TYPE_SIMPLE_CONTENT); parent.dispose(); attribute.setType(simpleContentType); checkIfAttributeReferenceIsNeeded(attribute, parentNamespace, typeSystemHolder); return attribute; }
protected Attribute processAttribute(XmlCursor xc, Inst2XsdOptions options, String parentNamespace, TypeSystemHolder typeSystemHolder) { assert xc.isAttr() : "xc not on attribute"; Attribute attribute = new Attribute(); QName attName = xc.getName(); attribute.setName(attName); XmlCursor parent = xc.newCursor(); parent.toParent(); Type simpleContentType = Type.createNamedType( processSimpleContentType(xc.getTextValue(), options, parent), Type.SIMPLE_TYPE_SIMPLE_CONTENT); parent.dispose(); attribute.setType(simpleContentType); checkIfAttributeReferenceIsNeeded(attribute, parentNamespace, typeSystemHolder); return attribute; }