cur.toFirstContentToken(); if (hashAlgo == null) { int hash = CryptoFunctions.createXorVerifier1(password);
c.toFirstContentToken(); // on <root> c.toFirstContentToken(); // on <a> d.toParent(); c.push(); System.out.println(generateXPath(c, d, ns)); c.pop(); c.toFirstContentToken(); // on text content of the last <c> c.push(); System.out.println(generateXPath(c, d, ns)); c.pop(); c.toParent();
/** * Computes how many text nodes the * @param c the position in the document * @return how many text nodes occur before the position determined by <code>c</code> */ private static int countTextTokens(XmlCursor c) { int k = 0; int l = 0; XmlCursor d = c.newCursor(); c.push(); c.toParent(); TokenType tt = c.toFirstContentToken(); while (!tt.isEnd()) { if (tt.isText()) { if (c.comparePosition(d) > 0) // We have moved after the initial position l++; else k++; } else if (tt.isStart()) c.toEndToken(); tt = c.toNextToken(); } c.pop(); return l == 0 ? 0 : k; }
node.setFoo("ABCDE12345"); XmlCursor c = node.xgetFoo().newCursor(); c.toFirstContentToken(); c.setBookmark(CDataBookmark.CDATA_BOOKMARK);
ContentType content = x.addNewContent(); content.setType("none"); XmlCursor cur = null; try { cur = content.newCursor(); cur.toFirstContentToken(); cur.insertChars("Hello World"); } finally { cur.dispose(); }
static XmlObject parseWithNamespaces(Element element, Map namespaceMap) throws XmlException { ArrayList errors = new ArrayList(); XmlOptions xmlOptions = XmlBeansUtil.createXmlOptions(errors); SchemaDocument parsed = SchemaDocument.Factory.parse(element, xmlOptions); if (errors.size() != 0) { throw new XmlException(errors.toArray().toString()); } XmlCursor cursor = parsed.newCursor(); try { cursor.toFirstContentToken(); for (Iterator namespaces = namespaceMap.entrySet().iterator(); namespaces.hasNext();) { Map.Entry entry = (Map.Entry) namespaces.next(); cursor.insertNamespace((String) entry.getKey(), (String) entry.getValue()); } } finally { cursor.dispose(); } return parsed; }
/** * * @param xml * @return */ XML prependChild (Object xml) { XmlCursor curs = newCursor(); if (curs.isStartdoc()) { curs.toFirstContentToken(); } // Move the cursor to the first content token curs.toFirstContentToken(); insertChild(curs, xml); curs.dispose(); return this; }
private static XML createXML (XMLLibImpl lib, XmlCursor curs) { if (curs.currentTokenType().isStartdoc()) { curs.toFirstContentToken(); } XScriptAnnotation anno = findAnnotation(curs); return new XML(lib, anno); }
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; }
private void appendXML(final XmlObject pAppendTo, final XmlObject pToAppend) { if (pToAppend == null) { return; } XmlCursor lValueCursor = pToAppend.newCursor(); lValueCursor.toFirstContentToken(); if (lValueCursor.isEnd()) { lValueCursor.dispose(); return; } // now append any elements XmlCursor lCursor = pAppendTo.newCursor(); lCursor.toFirstContentToken(); lValueCursor.moveXml(lCursor); lValueCursor.dispose(); lCursor.dispose(); }
/** * * @param curs */ protected void removeToken (XmlCursor curs) { XmlObject xo = XmlObject.Factory.newInstance(); // Don't delete anything move to another document so it gets orphaned nicely. XmlCursor tmpCurs = xo.newCursor(); tmpCurs.toFirstContentToken(); curs.moveXml(tmpCurs); tmpCurs.dispose(); }
/** * * @return */ Object copy() { XmlCursor srcCurs = newCursor(); if (srcCurs.isStartdoc()) { srcCurs.toFirstContentToken(); } XML xml = createEmptyXML(lib); XmlCursor destCurs = xml.newCursor(); destCurs.toFirstContentToken(); srcCurs.copyXml(destCurs); destCurs.dispose(); srcCurs.dispose(); return xml; }
/** * * @param name */ void setLocalName(String localName) { XmlCursor cursor = newCursor(); try { if(cursor.isStartdoc()) cursor.toFirstContentToken(); if(cursor.isText() || cursor.isComment()) return; javax.xml.namespace.QName qname = cursor.getName(); cursor.setName(new javax.xml.namespace.QName( qname.getNamespaceURI(), localName, qname.getPrefix())); } finally { cursor.dispose(); } }
private void createFilter(FilterType filterContainer, ParameterContainer parameters) throws XmlException { List<XmlObject> contentFilters = createContentFilters(parameters); String topicFilterText = getStringValueFor(SUBSCRIBE_FILTER_TOPIC, parameters); if (topicFilterText != null) { TopicExpressionDocument topicExpressionDoc = TopicExpressionDocument.Factory.newInstance(); TopicExpressionType topicExpression = topicExpressionDoc.addNewTopicExpression(); fillTopic(topicExpression, topicFilterText, getStringValueFor(SUBSCRIBE_FILTER_TOPIC_DIALECT, parameters)); contentFilters.add(topicExpressionDoc); } XmlCursor filterContainerCursor = filterContainer.newCursor(); filterContainerCursor.toFirstContentToken(); for (XmlObject filter : contentFilters) { XmlCursor cur = filter.newCursor(); cur.toFirstContentToken(); cur.copyXml(filterContainerCursor); } }
/** * * @return */ XmlCursor.TokenType tokenType() { XmlCursor.TokenType result; XmlCursor curs = newCursor(); if (curs.isStartdoc()) { curs.toFirstContentToken(); } result = curs.currentTokenType(); curs.dispose(); return result; } /**
import org.apache.xmlbeans.*; public class main { public static void main ( String[] args ) throws XmlException { XmlObject x = XmlObject.Factory.parse( "<BankRate> </BankRate>" ); XmlCursor c = x.newCursor(); c.toFirstContentToken(); c.toNextToken(); c.setBookmark(CDataBookmark.CDATA_BOOKMARK); XmlOptions options = new XmlOptions(); options.setSaveCDataLengthThreshold( 1 ); options.setUseCDataBookmarks(); System.out.print( x.xmlText( options ) ); } }
/** * Adds a set of namespaces to the SOAP-Envelope document. * * @param envelope * the {@link EnvelopeDocument} to which the namespace set is added */ public static void addNamespacesToEnvelope_000(Envelope envelope) { XmlCursor obsCursor = envelope.newCursor(); obsCursor.toFirstContentToken(); for (SesNamespace namespace : SesNamespace.values()) { obsCursor.insertNamespace(namespace.getPrefix(), namespace.getNamespace()); } // these are old // obsCursor.insertNamespace("wsbn","http://docs.oasis-open.org/wsn/br-2"); // obsCursor.insertNamespace("wsnt", "http://docs.oasis-open.org/wsn/b-2"); // obsCursor.insertNamespace("wsrf","http://docs.oasis-open.org/wsrf/rl-2"); } }
/** * * @return */ String localName() { XmlCursor cursor = newCursor(); if (cursor.isStartdoc()) cursor.toFirstContentToken(); String name = null; if(cursor.isStart() || cursor.isAttr() || cursor.isProcinst()) { javax.xml.namespace.QName qname = cursor.getName(); name = qname.getLocalPart(); } cursor.dispose(); return name; }
/** * * @return */ boolean hasSimpleContent() { boolean simpleContent = false; XmlCursor curs = newCursor(); if (curs.isAttr() || curs.isText()) { return true; } if (curs.isStartdoc()) { curs.toFirstContentToken(); } simpleContent = !(curs.toFirstChild()); curs.dispose(); return simpleContent; }
static XML createFromXmlObject(XMLLibImpl lib, XmlObject xo) { XScriptAnnotation anno; XmlCursor curs = xo.newCursor(); if (curs.currentTokenType().isStartdoc()) { curs.toFirstContentToken(); } try { anno = new XScriptAnnotation(curs); curs.setBookmark(anno); } finally { curs.dispose(); } return new XML(lib, anno); }