Java Code Examples for org.apache.xmlbeans.XmlCursor#isStart()
The following examples show how to use
org.apache.xmlbeans.XmlCursor#isStart() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultEbicsRootElement.java From ebics-java-client with GNU Lesser General Public License v2.1 | 6 votes |
/** * Inserts a schema location to the current ebics root element. * @param namespaceURI the name space URI * @param localPart the local part * @param prefix the prefix * @param value the value */ public void insertSchemaLocation(String namespaceURI, String localPart, String prefix, String value) { XmlCursor cursor; cursor = document.newCursor(); while (cursor.hasNextToken()) { if (cursor.isStart()) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName(namespaceURI, localPart, prefix), value); break; } else { cursor.toNextToken(); } } }
Example 2
Source File: DefaultEbicsRootElement.java From axelor-open-suite with GNU Affero General Public License v3.0 | 6 votes |
/** * Inserts a schema location to the current ebics root element. * * @param namespaceURI the name space URI * @param localPart the local part * @param prefix the prefix * @param value the value */ public void insertSchemaLocation( String namespaceURI, String localPart, String prefix, String value) { XmlCursor cursor; cursor = document.newCursor(); while (cursor.hasNextToken()) { if (cursor.isStart()) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName(namespaceURI, localPart, prefix), value); break; } else { cursor.toNextToken(); } } }
Example 3
Source File: XML.java From astor with GNU General Public License v2.0 | 6 votes |
/** * * @param xml * @return */ XML appendChild(Object xml) { XmlCursor curs = newCursor(); if (curs.isStartdoc()) { curs.toFirstContentToken(); } // Move the cursor to the end of this element if (curs.isStart()) { curs.toEndToken(); } insertChild(curs, xml); curs.dispose(); return this; }
Example 4
Source File: XML.java From astor with GNU General Public License v2.0 | 6 votes |
/** * * @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; }
Example 5
Source File: XML.java From astor with GNU General Public License v2.0 | 6 votes |
/** * * @return */ public String toString() { String result; XmlCursor curs = newCursor(); if (curs.isStartdoc()) { curs.toFirstContentToken(); } if (curs.isText()) { result = curs.getChars(); } else if (curs.isStart() && hasSimpleContent()) { result = curs.getTextValue(); } else { result = toXMLString(0); } return result; }
Example 6
Source File: ViisaregisterXTeeServiceImpl.java From j-road with Apache License 2.0 | 6 votes |
public TaotluseAndmedVastus taotluseAndmedNrLiikParing(String taotluseLiik, String taotluseNr) throws XRoadServiceConsumptionException { TaotluseAndmedNrLiikSisend paring = TaotluseAndmedNrLiikSisend.Factory.newInstance(); paring.setTaotluseLiik(com.nortal.jroad.client.viisaregister.types.ee.riik.xtee.viisaregister.producers.producer.viisaregister.TaotluseLiik.Enum.forString(taotluseLiik)); paring.setTaotluseNr(taotluseNr); //Kuna viisaregister tahab kindlasti oma xsi:type atribuute näha, siis paneme need käsitsi külge XmlCursor cursor = paring.newCursor(); while (!cursor.isEnddoc()) { if (cursor.isStart() && cursor.getName().getLocalPart().equals("taotluseLiik")) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "ns5:taotluseLiik"); } if (cursor.isStart() && cursor.getName().getLocalPart().equals("taotluseNr")) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:string"); } cursor.toNextToken(); } return viisaregisterXRoadDatabase.taotlAndmedNrLiikParingV1(paring); }
Example 7
Source File: DefaultEbicsRootElement.java From ebics-java-client with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void addNamespaceDecl(String prefix, String uri) { XmlCursor cursor; cursor = document.newCursor(); while (cursor.hasNextToken()) { if (cursor.isStart()) { cursor.toNextToken(); cursor.insertNamespace(prefix, uri); break; } else { cursor.toNextToken(); } } }
Example 8
Source File: DefaultEbicsRootElement.java From axelor-open-suite with GNU Affero General Public License v3.0 | 5 votes |
@Override public void addNamespaceDecl(String prefix, String uri) { XmlCursor cursor; cursor = document.newCursor(); while (cursor.hasNextToken()) { if (cursor.isStart()) { cursor.toNextToken(); cursor.insertNamespace(prefix, uri); break; } else { cursor.toNextToken(); } } }
Example 9
Source File: XML.java From astor with GNU General Public License v2.0 | 5 votes |
/** * * @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; }
Example 10
Source File: XML.java From astor with GNU General Public License v2.0 | 5 votes |
/** * * @param prefix * @return */ Object namespace(String prefix) { XmlCursor cursor = newCursor(); if (cursor.isStartdoc()) { cursor.toFirstContentToken(); } Object result = null; if (prefix == null) { if(cursor.isStart() || cursor.isAttr()) { Object[] inScopeNS = NamespaceHelper.inScopeNamespaces(lib, cursor); // XXX Is it reaaly necessary to create the second cursor? XmlCursor cursor2 = newCursor(); if (cursor2.isStartdoc()) cursor2.toFirstContentToken(); result = NamespaceHelper.getNamespace(lib, cursor2, inScopeNS); cursor2.dispose(); } } else { Map prefixToURI = NamespaceHelper.getAllNamespaces(lib, cursor); String uri = (String)prefixToURI.get(prefix); result = (uri == null) ? Undefined.instance : new Namespace(lib, prefix, uri); } cursor.dispose(); return result; }
Example 11
Source File: LogicalEquality.java From astor with GNU General Public License v2.0 | 4 votes |
public static boolean nodesEqual(XmlCursor xmlOne, XmlCursor xmlTwo) { boolean result = false; if (xmlOne.isStartdoc()) { xmlOne.toFirstContentToken(); } if (xmlTwo.isStartdoc()) { xmlTwo.toFirstContentToken(); } if (xmlOne.currentTokenType() == xmlTwo.currentTokenType()) { if (xmlOne.isEnddoc()) { // Both empty result = true; } else if (xmlOne.isAttr()) { result = attributesEqual(xmlOne, xmlTwo); } else if (xmlOne.isText()) { result = textNodesEqual(xmlOne, xmlTwo); } else if (xmlOne.isComment()) { result = commentsEqual(xmlOne, xmlTwo); } else if (xmlOne.isProcinst()) { result = processingInstructionsEqual(xmlOne, xmlTwo); } else if (xmlOne.isStart()) { // Compare root elements result = elementsEqual(xmlOne, xmlTwo); } } return result; }
Example 12
Source File: LogicalEquality.java From astor with GNU General Public License v2.0 | 4 votes |
private static boolean elementsEqual(XmlCursor xmlOne, XmlCursor xmlTwo) { boolean result = true; if (!qnamesEqual(xmlOne.getName(), xmlTwo.getName())) { result = false; } else { // These filter out empty text nodes. nextToken(xmlOne); nextToken(xmlTwo); do { if (xmlOne.currentTokenType() != xmlTwo.currentTokenType()) { // Not same token result = false; break; } else if (xmlOne.isEnd()) { // Done with this element, step over end break; } else if (xmlOne.isEnddoc()) { // Shouldn't get here break; } else if (xmlOne.isAttr()) { // This one will move us to the first non-attr token. result = attributeListsEqual(xmlOne, xmlTwo); } else { if (xmlOne.isText()) { result = textNodesEqual(xmlOne, xmlTwo); } else if (xmlOne.isComment()) { result = commentsEqual(xmlOne, xmlTwo); } else if (xmlOne.isProcinst()) { result = processingInstructionsEqual(xmlOne, xmlTwo); } else if (xmlOne.isStart()) { result = elementsEqual(xmlOne, xmlTwo); } else { //XML.log("Unknown token type" + xmlOne.currentTokenType()); } // These filter out empty text nodes. nextToken(xmlOne); nextToken(xmlTwo); } } while(result); } return result; }
Example 13
Source File: ViisaregisterXTeeServiceImpl.java From j-road with Apache License 2.0 | 4 votes |
public TaotlusteNimistuVastus taotluseAndmedIsikReisidokumentParing(String eesnimi, String perenimi, Calendar synniaeg, String sugu, String reisiDokLiik, String reisiDokNr, Calendar reisiDokValjastamisKuup, String toimik) throws XRoadServiceConsumptionException { TaotluseAndmedIsikReisidokSisend paring = TaotluseAndmedIsikReisidokSisend.Factory.newInstance(); if (eesnimi != null || perenimi != null || synniaeg != null || sugu != null) { StruktIsikSuguMK isik = paring.addNewIsik(); isik.setEesnimi(eesnimi); isik.setPerenimi(perenimi); isik.setSynniaeg(synniaeg); com.nortal.jroad.client.viisaregister.types.ee.riik.xtee.viisaregister.producers.producer.viisaregister.Sugu.Enum suguEnum = com.nortal.jroad.client.viisaregister.types.ee.riik.xtee.viisaregister.producers.producer.viisaregister.Sugu.Enum.forString(sugu); isik.setSugu(suguEnum); } com.nortal.jroad.client.viisaregister.types.ee.riik.xtee.viisaregister.producers.producer.viisaregister.ReisiDokLiik.Enum reisiDokLiikEnum = com.nortal.jroad.client.viisaregister.types.ee.riik.xtee.viisaregister.producers.producer.viisaregister.ReisiDokLiik.Enum.forString(reisiDokLiik); paring.setReisiDokLiik(reisiDokLiikEnum); paring.setReisiDokNr(reisiDokNr); paring.setReisiDokValjastamisKuup(reisiDokValjastamisKuup); //Kuna viisaregister tahab kindlasti oma xsi:type atribuute näha, siis paneme need käsitsi külge XmlCursor cursor = paring.newCursor(); while (!cursor.isEnddoc()) { if (cursor.isStart() && cursor.getName().getLocalPart().equals("isik")) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "ns5:struktIsikSuguMK"); } if (cursor.isStart() && cursor.getName().getLocalPart().equals("eesnimi")) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:string"); } if (cursor.isStart() && cursor.getName().getLocalPart().equals("perenimi")) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:string"); } if (cursor.isStart() && cursor.getName().getLocalPart().equals("synniaeg")) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:date"); } if (cursor.isStart() && cursor.getName().getLocalPart().equals("sugu")) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "ns5:sugu"); } if (cursor.isStart() && cursor.getName().getLocalPart().equals("reisiDokLiik")) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "ns5:reisiDokLiik"); } if (cursor.isStart() && cursor.getName().getLocalPart().equals("reisiDokNr")) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:string"); } if (cursor.isStart() && cursor.getName().getLocalPart().equals("reisiDokValjastamisKuup")) { cursor.toNextToken(); cursor.insertAttributeWithValue(new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"), "xsd:date"); } cursor.toNextToken(); } return viisaregisterXRoadDatabase.taotlAndmedIsikReisidokParingV1(paring); }