XmlValue on C++

Hi everyone.
Will someone give me advise on the following issue?
I am using dbxml-2.4.13 on Mac OSX Leopard. Compiler is g++ (gcc version 4.0.1).
I want to parse XML file using XmlValue that has methods like getFirstChild(), getNextSibling() and so on. However it did not work as I expected.
The following is an example of XML.
<document>
<math>
<apply> <eq />
<ci>V</ci>
<cn> x </cn>
</apply>
</math>
</document>
What I did is the following.
=========
XmlResults qresults = manager->query("doc('container/doc')/document/math");
XmlValue value;
qresults.next(value);
// for check
cerr << value.asString();
// showed <math> ... </math> ..... OK
cerr << value.getNodeName()
// showed "math" ..... OK
XmlValue child = value.getFirstChild();
cerr << child.getNodeName();
// showed "#text" ..... NG. I expected "apply"
XmlValue sibling = child.getNextSibling();
cerr << sibling.getNodeName();
// showed "apply" ...... ?? why?
=========
Why is not child "apply"?
Thank you for your help in advance.
Best regards,
yoshi

Lauren, thank you very much for your quick reply.
By changing the example XML text to <document><math><apply>..., the first child of "math" became "apply".
Then before I put the XMlL document into the container, should I remove all newlines from the document by myself as a preprocessing?
Or is there any methods provided by dbxml library?
yoshi

Similar Messages

  • How to get the Node Value from XmlValue result?

    Hi ,
    I am not able to get the Node Value from the result. In my XQuery im selecting till a Node, if i change my query as
    collection('PhoneBook')/phone_book/contact_person/address/string()", qc);
    im getting the node value, but here the problem is its not a Node so i cannot get the Node name.
    So how can i get the Node Name and Node value together?
    any help please ????
    XML :
    <?xml version="1.0" encoding="UTF-8"?>
    <phone_book>
    <contact_person>
    <name>
    <first_name>Michael</first_name>
    <second_name>Harrison</second_name>
    </name>
    <address city="yyyyy" pincode="600017" state="xxxxx">
    176 Ganesan street, Janakinagar, alwarthirunagar
    </address>
    </contact_person>
    <phone_number type="mobile">9881952233</phone_number>
    <phone_number type="home">044-24861311</phone_number>
    <phone_number type="office">080-12651174</phone_number>
    </phone_book>
    Code:
    XmlQueryContext qc = manager.createQueryContext();
    XmlResults rs = manager.query
    ("collection('PhoneBook')/phone_book/contact_person/address", qc);
    while(rs.hasNext()){
    XmlValue val = rs.next();
    System.out.println(val.getNodeName() + " = [ " + val.getNodeValue() + " ] ");
    Output
    address = [  ]

    You are right, this seemed un-intuitive to me too, but I finally understood how it's done.
    The "value" of a node is actually the total amount of text that is not contained in any of the node's child nodes (if any). So a node with child nodes can still have text value.
    To get the 'value' of an element node, you must therefore concatenate the values of all children of type "XmlValue::TEXT_NODE", of that node. Try it.
    In your example, the <address> node has no child elements, my guess is that BDB XML stores the address string "176 Ganesan street, Janakinagar, alwarthirunagar" inside a child node of <address> node (of type XmlValue::TEXT_NODE) because you wrote the string on a separate line.

  • I need to point the xmlValue.getParentNode().getNextSibling() node ?

    Hi,
    I am new to BDB development. Here i am working on node traversal using XmlValue class.
    I have some of the queries on traversing the nodes using XmlValue class….
    Steps followed for the same are as below…
    1. Opening the BDB Environment
    2. Loading the XML files in to the container(creating the container)
    3. Applied the requested Xquery on the container.
    4. After applying the Xquery on the container, the result is captured in to XmlResults class which is displayed as string format(as below).
    <HCR:hapGeminimmIINodeEntry hapGeminimmIINodeId="1">
    <HCR:hapGeminimmIINodeuserName>NULL</HCR:hapGeminimmIINodeuserName>
    <HCR:hapGeminiblackBoxLogStreamTable>
    <HCR:hapGeminiblackBoxLogStreamEntry hapGeminimmIINodeId="1" hapGeminiblackBoxLogStreamId="1">
    <HCR:hapGeminiblackBoxLogStreamloggingEnabled>2</HCR:hapGeminiblackBoxLogStreamloggingEnabled>
    </HCR:hapGeminiblackBoxLogStreamEntry>
    </HCR:hapGeminiblackBoxLogStreamTable>
    <HCR:hapGeminicoreFileMgmtLogStreamTable>
    <HCR:hapGeminicoreFileMgmtLogStreamEntry hapGeminimmIINodeId="1" hapGeminicoreFileMgmtLogStreamId="1">
    <HCR:hapGeminicoreFileMgmtLogStreamloggingEnabled>2</HCR:hapGeminicoreFileMgmtLogStreamloggingEnabled>
    <HCR:hapGeminicoreFileMgmtLogStreamconfigStreamLevel>1</HCR:hapGeminicoreFileMgmtLogStreamconfigStreamLevel>
    <HCR:hapGeminicoreFileMgmtLogStreamstreamDestination>NULL</HCR:hapGeminicoreFileMgmtLogStreamstreamDestination>
    </HCR:hapGeminicoreFileMgmtLogStreamEntry>
    </HCR:hapGeminicoreFileMgmtLogStreamTable>
    </HCR:hapGeminimmIINodeEntry>
    Rest of the code fragment for traversing the nodes are mentioned below…. Ignore the “#text” nodes
    Initially the variable “m_resultValue” of type XmlValue is pointing to the node <HCR:hapGeminimmIINodeEntry hapGeminimmIINodeId="1">
    XmlResults resultSet; // Result captured after applying the Xquery on the container….
    XmlValue m_resultValue;
    XmlValue tableValue;
    If(resultSet.next(m_resultValue))
    m_resultValue = m_resultValue.getFirstChild();
    while(!m_resultValue.isNull())
    If(The node name ends with Table)
    tableValue = m_resultValue; // Here tableValue is pointing to the node <HCR:hapGeminiblackBoxLogStreamTable>.
    tableValue = tableValue.getFirstChild(); // Here tableValue is pointing to the node <HCR:hapGeminiblackBoxLogStreamEntry hapGeminimmIINodeId="1" hapGeminiblackBoxLogStreamId="1">
    cout<<” Next Sibling of the node name hapGeminiblackBoxLogStreamTable is : “<<tableValue.getParentNode().getNextSibling().getLocalName<<endl; // Here I am expecting the Node Local Name as “hapGeminicoreFileMgmtLogStreamTable”. But this is displaying as empty…
    m_resultValue = m_resultValue.getNextSibling();
    From the above code fragment, I am expecting the output as “hapGeminicoreFileMgmtLogStreamTable”. But I am able to see the output as empty. Please let me know any suggestions on the same…
    Thanks in Advance,
    Regards,
    Sravan.

    Any white space between the element nodes, such as line returns, count as text children and have no local name. Is it possible that tableValue.getParentNode().getNextSibling() is returning the text node between&lt;HCR:hapGeminiblackBoxLogStreamTable&gt; and &lt;HCR:hapGeminicoreFileMgmtLogStreamTable&gt;?
    Lauren Foutz

  • How to create a node-typed XmlValue from a String with Java?

    Hi all,
    It's already been a while since I'm trying to get how to construct a node-typed XmlValue from a String value but I keep getting different exceptions no matter what method I try.
    I started with the first way that came to my mind:
    XmlValue value = new XmlValue("<element/>"); //Even though the String represents a valid xml node, calling value.isString() returns true.
    then I thought ok, so I should maybe use the typed constructor:
    XmlValue value = new XmlValue(XmlValue.NODE, "<element/>"); //_It does not work either, calling value.isNull() returns true.
    I also tried with the rest of types (XmlValue.DOCUMENT, XmlValue.DOCUMENT_NODE, XmlValue.ELEMENT_NODE.....) and it did not work either with any of these.
    Fiinally I saw that you can construct a new XmlValue from a XmlDocument but I cannot get a XmlDocument unless I phisically create one, which obviously wont be a very good idea.
    So I'm definitely stuck with these, I would really appreciate if someone could tell me how to do this...
    Thanks in advance,
    Pablo Pareja
    PS: I'm using Berkeley dbxml 2.5.13

    Hi Pablo,
            XmlDocument doc = manager.createDocument();
            doc.setContent("<bla/>");
            XmlValue val = new XmlValue(doc);
            System.out.println(val.getType() == XmlValue.NODE);
            System.out.println(val.asString());Try this. It doesn't create physically (that is in the container) a document. The output of this piece of program:
    true
    <bla/>Hope it helps
    Vyacheslav

  • Thread-safe alternative to XmlValue

    Hi,
    I'm using bdb xml in an application which visualizes 3d data stored in xml. When I load the data, it will be written into the db and I#m using XPath as query language. This works quite good, but as I'm using multiple threads within my application, I can't use XmlValues for referencing into the database, because they are not thread-safe. But I need to store at least some of those references to get quick access to some data, or to run a new query, based on a result node from an earlier query, later from another thread. Those referenced nodes will change during runtime, so indices won't help. So what can I do or did I miss something?
    Thanks
    Bjoern

    Bjoern,
    You may have to explain a bit more, especially the part about "referenced nodes will change during runtime." XmlValue objects that reference nodes are only guaranteed valid until the either (1) the XmlResults object containing them has been deleted or (2) the transaction in which they were retrieved ends. There are exceptions but those are the general rules.
    The interfaces, XmlValue::getNodeHandle() and XmlContainer::getNode() exist to allow an application to store a string value that can be later resolved quickly back into an XmlValue. This works well unless the referenced node has been removed. It may be the answer you are looking for.
    Regards,
    George

  • Bug in 2.5.13 Java XmlValue.getAttributes()

    There seems to be some issue with properly deleting the XmlResults from XmlValue.getAttributes() using the Java api. Here is a sample function to illustrate the issue:
    private static void runAQuery(XmlManager manager, String query) {
                    System.out.println("Running query: "+query);
                    XmlResults queryRes = null;
                    try {
                            final XmlQueryContext qc =
                                    manager.createQueryContext(XmlQueryContext.LiveValues, XmlQueryContext.Lazy);
                            queryRes = manager.query(query, qc);
                            XmlValue temp;
                            while(queryRes.hasNext()) {
                                    temp = queryRes.next();
                                    XmlResults attrRes = temp.getAttributes();
                                    XmlValue t = attrRes.next();
                                    System.out.println("Saw attr name: "+t.getNodeName());
                                    attrRes.delete();
                    } catch(XmlException e) {
                            e.printStackTrace();
                    } finally {
                            if(queryRes != null) {
                                    queryRes.delete();
            }Running this produces:
    Running query: (collection('db.dbxml')/scenario)[1]
    Saw attr name: name
    com.sleepycat.dbxml.XmlException: null object - call after object destroyed?, errcode = INVALID_VALUE
         at com.sleepycat.dbxml.dbxml_javaJNI.XmlResults_hasNext(Native Method)
         at com.sleepycat.dbxml.XmlResults.hasNext(XmlResults.java:142)
         at test.runAQuery(test.java:41)
         at test.main(test.java:24)So it seemed maybe I should not delete the attribute results however if I comment out:
                                    //attrRes.delete();and see what what happens, I get:
    Running query: (collection('db.dbxml')/scenario)[1]
    Saw attr name: name
    Database handles still open at environment close
    Open database handle: db.dbxml/structural_stats
    Open database handle: db.dbxml/secondary_document_statistics_double
    Open database handle: db.dbxml/secondary_document_index_double
    Open database handle: db.dbxml/secondary_document_statistics_string
    Open database handle: db.dbxml/secondary_document_index_string
    Open database handle: db.dbxml/node_nodestorage
    Open database handle: db.dbxml/secondary_document
    Open database handle: db.dbxml/secondary_dictionary
    Open database handle: db.dbxml/primary_dictionary
    Open database handle: db.dbxml/secondary_sequence
    Open database handle: db.dbxml/secondary_configuration
    Exception in thread "main" java.lang.IllegalArgumentException: Invalid argument
         at com.sleepycat.db.internal.db_javaJNI.DbEnv_close0(Native Method)
         at com.sleepycat.db.internal.DbEnv.close0(DbEnv.java:268)
         at com.sleepycat.db.internal.DbEnv.close(DbEnv.java:79)
         at com.sleepycat.db.Environment.close(Environment.java:141)
         at com.sleepycat.dbxml.XmlManager.closeInternal(XmlManager.java:418)
         at com.sleepycat.dbxml.XmlManager.delete(XmlManager.java:35)
         at com.sleepycat.dbxml.XmlManager.close(XmlManager.java:427)
         at test.main(test.java:31)Thanks,
    Pralit

    I concur. I can also see such a bug in DB XML 2.5. :(( Probably closing of the attrRes object implicitly causes closing of the queryRes object (partially?). One hack solution would be to keep all atrrRes objects somewhere and close them together with queryRes objects.
    Vyacheslav

  • Xmldocument as xmlvalue context value question

    why is it that when i use an xmldocument (wrapped by an xmlvalue object) as a context value for xmlqueryexpression.execute() and if my query returns nodes (rather than scalars like string(), etc), the resulting xmlresults' xmlvalue objects return empty string for .asString()?
    i'm completely new to this approach for using xmldocument as a starting query context. i'm trying this because i figure doing this is better than using doc() because you get to reuse the same xmlqueryexpressions objects across different documents.
    so for instance:
              XmlDocument document = xmlContainer.getDocument("catalog2", XmlDocumentConfig.DEFAULT);
              XmlQueryContext ctx = xmlManager.createQueryContext();
              XmlQueryExpression expr = xmlManager.prepare("/catalog/journal/article", ctx);
              XmlResults results = null;
              try {
                   results = expr.execute(new XmlValue(document), ctx);
                   List<String> articles = new ArrayList<String>();
                   try {
                        if (results != null) {
                             if (results.size() > 0) {
                                  XmlValue value = results.next();
                                  while (value != null) {
                                       articles.add(value.asString());
                                       value = results.next();
                   finally {
                        if (results != null) results.delete();
                   assertEquals(2, articles.size()); // correct!
                   for (String string : articles) {
                        System.out.println(string);
                        assertFalse(StringUtils.isEmpty(string));  // empty strings!
              finally {
                   results.delete();
                   expr.delete();
                   document.delete();
    any ideas? thanks.

    Hi wvuong,
    You can reuse xmlqueryexpression objects across different documents simply by XmlQueryContext::setVariableValue().
    Here is an example in C++( sorry, I'm not good at Java ). Please refere the docs if you want more details about using XmlQueryContext::setVariableValue in Java.
    // Define XmlQueryExpression using "doc_name" as Variable
    XmlQueryContext qc = mgr.createQueryContext();
    qc.setVariableValue("doc_name", "");
    string query = "for $node in doc($doc_name) return <l1>{$node}</l1>";
    XmlQueryExpression expr = mgr.prepare(query, qc);
    // Using the XmlQueryExpression
    string docName = collection_name + "/" + "THE_DOC_NAME";
    qc.setVariableValue("doc_name", docName);
    XmlResults res = expr.execute( qc );

  • @XmlAttribute/@XmlValue need to reference a Java type that maps to text

    Hi,
    I get this exception when marshalling with xjc (either 2.0.1 or 2.1.3) generated classes. The xsd looks like this:
    <xs:complexType name="ExtensionType">
         <xs:simpleContent>
              <xs:extension base="xs:anySimpleType">
                   <xs:attribute name="nombre" use="required">
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:maxLength value="50"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:attribute>
                   <xs:attribute name="tipo" use="optional">
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:minLength value="0"/>
                                  <xs:maxLength value="30"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:attribute>
                   <xs:attribute name="id" use="optional">
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:minLength value="0"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:attribute>
              </xs:extension>
         </xs:simpleContent>
    </xs:complexType>and the generated class looks like
    public class ExtensionType {
        @XmlValue
        protected Object value;
        @XmlAttribute
        protected String id;
        @XmlAttribute(required = true)
        protected String nombre;
        @XmlAttribute
        protected String tipo;
    }If I change value's type to String I don't get the error any more. I've tried some binding customizations, but without luck.
    Any hints on how to a) customize de binding or b) modify the schema so that jaxb doesn't choke on xjc's bindings?
    tks

    I am running into the same problem. I need an @XmlValue to be an Object (xs:anyType). Here are the basic annotations:
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "argument")
    public class Argument {
        @XmlAttribute(name = "type")
        protected String type;
        @XmlValue
        protected Object value;
    }The desired output is as follows:
    <argument type="arg1.type"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">
        test
    </argument>However, I am getting the same exception: "@XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML." when attempting to marshal.
    Any suggestions would be appreciated.

  • XmlValue for root node

    Hello,
    I have inserted the following documents into a container:
    <root><value>bob</value></root>
    <anotherRoot><value>bob</value></anotherRoot>
    <anotherRoot><value>bill</value></anotherRoot>
    <anotherRoot><value>fred</value></anotherRoot>I am then attempting to construct a query that extracts the right documents based on the root node name in a variable:
    qc.setVariableValue('container', XmlValue('test.dbxml'))
    qc.setVariableValue('root', XmlValue('anotherRoot'))
    collection($container)/$rootHowever, the results I get are rather strange (XmlResult.asString()):
    anotherRoot
    anotherRoot
    anotherRoot
    anotherRootAny ideas?

    Hi,
    Not sure what you mean by "works as expected", but I guess it does something different that you think. If you predicate consists of a string variable (and in your case $nodeName is a string), then this predicate will return true if a string has non-zero length.
    A quite from the XPath spec:
    If its operand is a singleton value of type xs:string, xs:anyURI, xs:untypedAtomic, or a type derived from one of these,
      fn:boolean returns false if the operand value has zero length; otherwise it returns true.That's how a boolean value of the predicate is constructed for strings.
    So the query:
    collection($container)/anotherRoot[$nodeName]just will return all anotherRoot elements given that $nodeName is not an empty string, whereas
    collection($container)/anotherRoot[""]
    OR
    collection($container)/anotherRoot[()]will return zero results
    To sum up, a query:
    $nodes["string"]will behave exactly as just:
    $nodesHope this helps,
    Vyacheslav

  • Trouble with XmlValue.getAttributes in 2.4.11

    When I try to use the results from a getAttributes from a query result I get an exception such as:
    com.sleepycat.dbxml.XmlException: The XmlValue does not have an XmlResult or XmlManager., errcode = INTERNAL_ERROR
            at com.sleepycat.dbxml.XmlValue$NodeValue.getResult(XmlValue.java:735)
            at com.sleepycat.dbxml.XmlValue$NodeValue.getNodeValue(XmlValue.java:908)
            at com.sleepycat.dbxml.XmlValue.getNodeValue(XmlValue.java:215)
            at test.main(test.java:37)I am using DB XML version 2.4.11 on Mac OSX 10.4.11 and Java 1.5.0_13.
    The following is a simplified example that reproduces the error.
    Thanks,
    Pralit
    public static void main(String[] args) throws Exception {
         final EnvironmentConfig envConfig = new EnvironmentConfig();
         envConfig.setAllowCreate(true);
         envConfig.setCacheSize(100 * 1024 * 1024 );
         envConfig.setInitializeCache(true);
         envConfig.setInitializeLocking(true);
         final File path = new File(".");
         final String contName = "temp.dbxml";
         final Environment dbEnv = new Environment(path, envConfig);
         final XmlManagerConfig mc = new XmlManagerConfig();
         mc.setAdoptEnvironment(true);
         final XmlManager manager = new XmlManager(dbEnv, mc);
         final XmlContainerConfig cconfig = new XmlContainerConfig();
         final XmlContainer container = manager.openContainer(contName, cconfig);
         // catch these errors so I can close the container
         XmlResults queryRes = null;
         XmlResults attrRes = null;
         try {
              final XmlQueryContext qc =
                   manager.createQueryContext(XmlQueryContext.LiveValues, XmlQueryContext.Lazy);
              queryRes = manager.query("collection('"+contName+"')/scenario", qc);
              XmlValue temp;
              while(queryRes.hasNext()) {
                   temp = queryRes.next();
                   attrRes = temp.getAttributes();
                   while(attrRes.hasNext()) {
                        //System.out.println("attr name "+attrRes.next().getNodeName());
                        System.out.println("attr value "+attrRes.next().getNodeValue()); // exception here
                   attrRes.delete();
              queryRes.delete();
         } catch(XmlException e) {
              e.printStackTrace();
              if(attrRes != null) {
                   attrRes.delete();
              if(queryRes != null) {
                   queryRes.delete();
         } finally {
              container.close();
              manager.close();
    }

    I tried the patch you sent with no luck, same error. I then tried the test on an intel based mac (without the patch) and that had no problems. That machine was running the same version os/dbxml/java as my machine (G4 PowerPC). It had a slightly newer gcc so I updated gcc on my machine to powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367) however same error.
    I am not going to worry about this for the time being but thought maybe this info may be useful for you. If you need more info feel free to ask.
    Thanks,
    Pralit

  • Methods of XmlValue evoke error on Python

    Dear all
    I have problems on usage of methods of XmlValue of Python API.
    Assume that I have the following XML text
    &lt;a&gt;
    &lt;b&gt; hello &lt;/b&gt;
    &lt;c&gt; bye &lt;/c&gt;
    &lt;/a&gt;
    and now I try to retrieve a node &lt;b&gt; as
    results = manager.query('doc("test.dbxml/tmp")/a/b', qcontext)
    where "results" is an object of XmlResults.
    Taking the first element of the "results" as
    node = results.next()
    where "node" is an object of XmlValue, and is supposed to point to &lt;b&gt;.
    I try to take its next sibling, i.e. &lt;c&gt;, as
    nextnode = node.getNextSibling()
    Then this code stopped with segmentation fault here.
    The same error occured with getParentNode(). getNodeName(), getPrefix() etc.
    However, for example, the following is working;
    results = manager.query('doc("test.dbxml/tmp")/a/b/text()', qcontext)
    print results.next().asString()
    This returns "hello" correctly.
    And many other things like modify.addAppendStep() etc are working.
    Is this due to my python code or due to library?
    Did anyone succeed to use these methods?
    I am working on Mac OSX with DBXML 2.4.16 and BDB 4.6.21.
    Thank you in advance for your help.
    -yoshi

    Hi Yoshi,
    I'm relatively new to dbxml but it seems to me the behaviour you describe is correct:
    This query, results = manager.query('doc("test.dbxml/tmp")/a/b', qcontext), returns only b; in the result set b has no siblings. Within a query you could ask for b's first sibling (somthing like .../a/b/(following-sibling::*)[1]) but not in the results when the results contain only b.
    Or, am I missing something here?
    Cheers,
    John

  • Problem setting XmlValue type throug PHP api

    When i try to add metadata to a document and set its value to DATE_TIME i get an error:
    Warning: xmlvalue::xmlvalue() expects exactly 1 parameter, 2 given in ...Code:
    $v = new XmlValue(XmlValue_DATE_TIME, "2006-01-01T01:01:01");
    Can i set specific metadata types through php?
    Thank you.

    Apply this patch to dbxml/src/php/php_dbxml_value.cpp and it will work.
    Index: php_dbxml_value.cpp
    ===================================================================
    RCS file: /a/CVSROOT/xml/src/php/php_dbxml_value.cpp,v
    retrieving revision 1.16
    diff -r1.16 php_dbxml_value.cpp
    35c35,38
    <
    long type;
    char *value;
    int valueLen;
    40,41c43
    <   }
    <   else if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!", &val)) {
    } else if (SUCCESS == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z!", &val)) {43a46,48
    } else if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &value, &valueLen)) {
    This = XmlValue((XmlValue::Type)type, value);
    php_dbxml_set_XmlValue_object_pointer(getThis(), This TSRMLS_CC);

  • Generate Valid XML from pl/sql

    Hi,
    A new-bee here. I want to know how to generate a valid xml document. I have a schema which by the way includes two other schemas. This is the code I am using but I don't know how to make sure that I insert the child nodes in the right sequence. Any sample code that you guys can provide would be greatly appreciated.
    FUNCTION GenerateOrderXML(
              o_ErrorCode     OUT     NUMBER,
              o_ErrorText     OUT     VARCHAR2,
              i_AccountID     IN     document.documentid%TYPE,
              i_OrderName IN VARCHAR2) RETURN XMLType
    IS
         v_Doc     XMLDOM.DOMDocument;
         v_MainNode     XMLDOM.DOMNode;
         v_RootElmt     XMLDOM.DOMElement;
         v_RootNode     XMLDOM.DOMNode;
         v_TmpCLOB     CLOB := ' ';
    CURSOR CURSOR_SERVOBJ
              IS
              SELECT XMLTAG, XMLVALUE FROM SERVICEOBJECT
                   WHERE SERVICEOBJECT.ID < 500
                   ORDER BY SEQUENCE;
    -- Create xml root element
         v_Doc := XMLDOM.newDOMDocument;
         v_MainNode := XMLDOM.makeNode(v_Doc);
         v_RootElmt := XMLDOM.createElement(v_Doc, 'OrderRequest');
         v_RootNode := XMLDOM.appendChild(v_MainNode, XMLDOM.makeNode(v_RootElmt));
         -- Add OrderName, OrderType
         AddChild(v_Doc, v_RootNode, 'orderName', i_OrderName);
         AddChild(v_Doc, v_RootNode, 'orderType', 'NA');
         -- Add all attributes
         FOR v_NameValue IN CURSOR_SERVOBJ
         LOOP
              AddChild(v_Doc, v_RootNode, v_NameValue.XMLTAG, v_NameValue.XMLVALUE);
         END LOOP;
         --     XMLDOM.writeToBuffer(v_Doc, v_Buffer);
         XMLDOM.writeToClob(v_Doc, v_TmpCLOB);
         o_ErrorCode := 0;
         RETURN XMLType.createXML(v_TmpClob);
    END;

    The r was a typo. The messge is correct.
    Here is another problem I am having. I can't import a schema that includes another schema. When I try to register the third schema I get the following error. The first two register without any errors and when I run this
    select schema_url from user_xml_schemas;
    I see
    http://www.bbc.com/XMLSchema/sfi.xsd
    http://www.bbc.com/XMLSchema/ProductModel.xsd
    So why is my third schema not importing? Can you point me to any good documentation/tutorials on XML DB.
    Note: Thank you for your help so far.
    ERROR at line 1:
    ORA-31000: Resource 'ProductModel.xsd' is not an XDB schema document
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 0
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 26
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 131
    ORA-06512: at line 6
    1st Schema Heading
    <xsd:schema xmlns="http://www.bbc.com/XMLSchema/bfi.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.bbc.com/XMLSchema/bfi.xsd" elementFormDefault="qualified">
    2nd Schema Heading
    <xsd:schema xmlns="http://www.bbc.com/XMLSchema/ProductModel.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.bbc.com/XMLSchema/ProductModel.xsd" elementFormDefault="qualified">
    3rd Schema Heading
    <xsd:schema xmlns="http://www.bbc.com/XMLSchema/ResourceOrder.xsd" xmlns:qb="http://www.bbc.com/XMLSchema/ProductModel.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.bbc.com/XMLSchema/ResourceOrder.xsd" elementFormDefault="qualified">
    <xsd:import namespace="http://www.bbc.com/XMLSchema/ProductModel.xsd" schemaLocation="ProductModel.xsd"/>

  • Returning an XmlDocument from an external function?

    Hi,
    In an attempt to simplify my XQueries, I have started looking at writing some of the more complex functions in Java and calling them via an XmlExternalFunction.
    This seems fine, except that I have an issue with returning a constructed document (or any node set). The only way I have found to return a document without it being destroyed is to put it into a temporary database first. Here is the end of my function. I have written a convenience function that converts a DOM Xml Document into a dbxml XmlDocument (DomToXmlDbDoc).
         XmlResults results = mgr.createResults();
         XmlDocument result = DomToXmlDbDoc(doc);
         XmlContainer tmp = mgr.openContainer(txn, "_tmp.dbxml");
         result.setName(UUID.randomUUID().toString());
         putDocument(tmp, result);
         tmp.close();
         XmlValue value = new XmlValue(result);
         results.add(value);
         return results;
    I would prefer not to have to use the temporary storage in the middle as it is inefficient and rather untidy, but the following just gives a blank result.
         XmlResults results = mgr.createResults();
         XmlDocument result = DomToXmlDbDoc(doc);
         XmlValue value = new XmlValue(result);
         results.add(value);
         return results;
    Best Regards
    Pete.

    Hi,
    this is a bug in DB XML, namely in Java bindings. I could try to search a patch for this (which is not very well tested though) and send you by email if you tell me your address.
    Vyacheslav

  • !Question about EventReaderToWriter

    I am trying to store the content from a query result result to a document, I do like this:
    // write the start document and root element
    xWriter.writeStartDocument(NULL, NULL, NULL); // no XML decl
    xWriter.writeStartElement((const unsigned char *)"_root", NULL, NULL, 0, false);
    // do some query operation
    XmlResults res = expr.execute(qc, 0);
    // I can print to see all the results in res
    // but when I do like this, there is an assertion error from dbgdel.cpp with Expression:_BLOCK_TYPE_IS_VALID(pHead->nBlockUse), can somebody give me some advice on this?
    while ( res.next(value) ) {
    XmlDocument xDoc = value.asDocument();
    XmlEventReader xReader = xDoc.getContentAsEventReader();
    XmlEventReaderToWriter ReaderToWriter(xReader, xWriter);
    ReaderToWriter.start();
    xReader.close();
    // write the end of root element and endDocument
    xWriter.writeEndElement((const unsigned char *)"_root", NULL, NULL);
    xWriter.writeEndDocument();
    Message was edited by:
    user566957
    Message was edited by:
    user566957
    Message was edited by:
    user566957
    Message was edited by:
    user566957

    Joe,
    I see what you are trying to do, but the current API does not work in the way you want. It's a good idea to be able to use multiple XmlEventReader instances against a single XmlEventWriter using XmlEventReaderToWriter, but you can't do that right now.
    The problem you are seeing is that XmlEventReaderToWriter.start() will call close() on the writer when it's done, which deletes its memory.
    I'll look into enhancing XmlEventReaderToWriter to be more friendly along these lines. In the meantime, you have a few choices. One is to write the equivalent of XmlEventReaderToWriter yourself -- it's a very simple implementation. You can look at the C++ implementation in dbxml/src/dbxml/nodeStore/EventReaderToWriter.cpp.
    You could also modify the existing code in dbxml/src/dbxml/XmlEventReaderToWriter.cpp to not call XmlEventWriter.close() at the end of the start() method. You'd then have to close the writer yourself. I don't think there would be any negative side effects, since that interface is not used by BDB XML itself, but I don't make any promises.
    One more thing -- I'd recommend calling XmlValue.asEventReader() directly with your XmlValue objects, rather than going via value.asDocument(). Unless you really want the entire documents involved, there's no reason to add that step.
    Let me know how this works out.
    Regards,
    George

Maybe you are looking for

  • Is the ATI Radeon HD 4870 quiter than the NVidia GeForce 8800 GT ?

    My NVidia GeForce 8800 GT just died and I have the choice to have the same one installed or to to go for the ATI 4870. (Technically I prefer the ATI but my family would prefer the quieter one!) My main concern is the noise. Is the 4870 quieter or noi

  • Sender SOAP Adapter problem in PI 7.1

    Hello Everyone, I have a problem with Sender SOAP  Adapter In PI 7.0 i am able to receive the messages through sender SOAP Adapter for both HTTP and HTTPS. But when i am testing in PI 7.1 i am unable to receive any messages at Adapter level for both

  • R3trans does work on NetWeaver 7.01 ABAP Trial Version

    Hi, I have just installed a NetWeaver 7.01 ABAP Trial Version on my laptop(Windows). I need to run "r3trans" command on this system, but it failed, the error message said "connect failed with DBLI_RC_LOAD_LIB_FAILED". When I executed the "r3trans" co

  • Brconnect Error ORA-12637: Packet receive failed

    Hello, We have a problem with Brconnect (42). When I start the brconnect program in DB13 transaction I get a following error message. The error come when I start the brconnect program under user sapservice(SID). When I start the brconnect program und

  • Add new contact person in contact management

    Hi All, I have been created email in contact management(SRM). in Tab "General", Contact person field, i cannot select new item/New contact person from combobox. I have read at HELP file,then i found to add new contact person in contact management, go