/** * Verifies that cursor is on the right position. * * @param cursor * @return true if the cursor is within a CTFtnEdn element. */ private boolean isCursorInFtn(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); if (verify.getObject() == this.ctFtnEdn) { return true; } return false; }
/** * verifies that cursor is on the right position * * @param cursor */ private boolean isCursorInHdrF(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); boolean result = (verify.getObject() == this.headerFooter); verify.dispose(); return result; }
/** * verifies that cursor is on the right position */ private boolean isCursorInTableCell(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); boolean result = (verify.getObject() == this.ctTc); verify.dispose(); return result; }
/** * verifies that cursor is on the right position * * @param cursor */ private boolean isCursorInBody(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); boolean result = (verify.getObject() == this.ctDocument.getBody()); verify.dispose(); return result; }
private static final String formatQName(XmlCursor xmlc, QName qName) { XmlCursor parent = xmlc.newCursor(); parent.toParent(); String prefix = parent.prefixForNamespace(qName.getNamespaceURI()); parent.dispose(); String name; if (prefix == null || prefix.length() == 0) name = qName.getLocalPart(); else name = prefix + ":" + qName.getLocalPart(); return name; }
private boolean isCursorInBody(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); try { return true;// (verify.getObject() == this.getDocument().getBody()); } finally { verify.dispose(); } }
XmlCursor xcForNamespaces = xc.newCursor(); xcForNamespaces.toParent();
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; }
XmlCursor c = cursor.newCursor();
private static String generateInternal(XmlCursor node, XmlCursor context, NamespaceContext nsctx) throws XPathGenerationException { if (node.isStartdoc()) return ""; if (context != null && node.isAtSamePositionAs(context)) return "."; assert node.isStart(); QName name = node.getName(); XmlCursor d = node.newCursor(); if (!node.toParent()) return "/" + name; int elemIndex = 0, i = 1; node.push(); if (!node.toChild(name)) throw new IllegalStateException("Must have at least one child with name: " + name); do { if (node.isAtSamePositionAs(d)) elemIndex = i; else i++; } while (node.toNextSibling(name)); node.pop(); d.dispose(); String pathToParent = generateInternal(node, context, nsctx); return i == 1 ? pathToParent + '/' + qnameToString(name, nsctx) : pathToParent + '/' + qnameToString(name, nsctx) + '[' + elemIndex + ']'; }
/** * 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; }
XmlCursor d = c.newCursor(); d.toParent(); c.push(); System.out.println(generateXPath(c, d, ns)); c.pop();
private static final String formatQName(XmlCursor xmlc, QName qName) { XmlCursor parent = xmlc.newCursor(); parent.toParent(); String prefix = parent.prefixForNamespace(qName.getNamespaceURI()); parent.dispose(); String name; if (prefix == null || prefix.length() == 0) name = qName.getLocalPart(); else name = prefix + ":" + qName.getLocalPart(); return name; }
private static final String formatQName(XmlCursor xmlc, QName qName) { XmlCursor parent = xmlc.newCursor(); parent.toParent(); String prefix = parent.prefixForNamespace(qName.getNamespaceURI()); parent.dispose(); String name; if (prefix == null || prefix.length() == 0) name = qName.getLocalPart(); else name = prefix + ":" + qName.getLocalPart(); return name; }
/** * verifies that cursor is on the right position */ private boolean isCursorInTableCell(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); if(verify.getObject() == this.ctTc){ return true; } return false; }
/** * verifies that cursor is on the right position * @param cursor */ private boolean isCursorInHdrF(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); if(verify.getObject() == this.headerFooter){ return true; } return false; }
/** * verifies that cursor is on the right position * @param cursor */ private boolean isCursorInFtn(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); if(verify.getObject() == this.ctFtnEdn){ return true; } return false; }
/** * verifies that cursor is on the right position * * @param cursor */ private boolean isCursorInHdrF(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); boolean result = (verify.getObject() == this.headerFooter); verify.dispose(); return result; }
/** * verifies that cursor is on the right position */ private boolean isCursorInTableCell(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); boolean result = (verify.getObject() == this.ctTc); verify.dispose(); return result; }
/** * verifies that cursor is on the right position * * @param cursor */ private boolean isCursorInBody(XmlCursor cursor) { XmlCursor verify = cursor.newCursor(); verify.toParent(); boolean result = (verify.getObject() == this.ctDocument.getBody()); verify.dispose(); return result; }