QueryError "It is error for context item undefined when using[err:XPDY0002]

Hi,
I a beginner for DB XML with python, below is my script and i have error
"def next(*args): return _dbxml.XmlResults_next(*args)
RuntimeError: Error: It is an error for the context item to be undefined when using it [err:XPDY0002], <query>:1:12" when i executed my scripts. Pls advice. Thank you.
import sys
from dbxml import *
from bsddb3.db import *
class DbXml:
def createEnvironment(self, home):
""" Create DBEnv and initialize XmlManager"""
try:
environment = DBEnv()
environment.open(home, DB_RECOVER|DB_CREATE|DB_INIT_LOCK|
DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN, 0)
except DBError, exc:
print exc
sys.exit()
try:
mgr = XmlManager(environment, 0)
except XmlException, se:
print se
sys.exit()
return mgr
def closeEnvironment(self):
""" Close DBEnv environment"""
environment = DBEnv()
environment.close()
def createContainer(self, mgr, containerName):
""" Create/open a node container"""
if mgr.existsContainer(containerName) != 0:
mgr.removeContainer(containerName)
try:
return mgr.createContainer(containerName,
DBXML_TRANSACTIONAL|DBXML_ALLOW_VALIDATION,
XmlContainer.NodeContainer)
except XmlException, ex:
print ex
sys.exit()
def putDocument(self, mgr, cont, file, DocName):
""" put xml document in database"""
self.docName = DocName
f = open(file)
q = f.read()
f.close()
try:
# all Container modification operations need XmlUpdateContext
uc = mgr.createUpdateContext()
txn = mgr.createTransaction()
try:
docName = cont.putDocument(txn, self.docName,
q, uc) #, DBXML_GEN_NAME)
txn.commit()
except XmlException, ex:
print ex
txn.abort()
txn = mgr.createTransaction()
doc = cont.getDocument(txn, self.docName)
name = doc.getName()
docContent = doc.getContentAsString()
txn.commit()
print "Document name: ",name,"\nContent: ",docContent
except XmlException, inst:
print inst
if txn:
txn.abort()
def query(self, mgr, cont, queries):
""" Query"""
myQuery = r"collection(" + cont + ")" + "/" + queries
myContainer = mgr.openContainer(cont)
qContext = mgr.createQueryContext()
qContext.setEvaluationType(XmlQueryContext.Lazy)
results = mgr.query(myQuery, qContext)
for value in results:
document = value.asDocument()
name = document.getName()
content = value.asString()
print name, ":", content
if __name__ == "__main__":
dbxml = DbXml()
mgr = dbxml.createEnvironment(".")
cont = dbxml.createContainer(mgr, "test.dbxml")
dbxml.putDocument(mgr, cont, "C:\Documents and Settings\uidc0998\Desktop\\books.xml", "books.xml")
dbxml.query(mgr, "test.dbxml", "bookstore/book/title")
dbxml.closeEnvironment()
Edited by: user10951778 on Mar 31, 2009 5:47 PM

Hi rucong.zhao,
Below is my xml, may i know what type of namespace or what i should put for namespace? Thank you.
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>

Similar Messages

  • Display Item cleared when using 'Enter-Query'

    Hi all,
    i am going to develop a multilanguage application with very
    special heading texts using display items for these headings.
    BUT- if I press EnterQuery, they are cleared also.
    How can I restrict cleanup of these display items used as
    headings ?
    I was looking in the properties, but no idea.
    Thanks for help,
    udo

    I'm showing how to do it when switching modes. I'm
    not suggesting this is the best way to do a query.We need to look at this in the context of the original probelm in the thread linked to above. For most cases the when-timer-expired etc is just a huge detour around using the pre-query trigger but it's an interesting approach to the specific problem in the earlier thread. The OP there wanted to be able to type '>5000' into a number field in a non-database block, which we can do in a database block in enter-query mode, and use it as a query parameter in the database block. Perhaps if we enter this into a character field in the non-database block and populate the numeric field in the database block whilst in enter-query mode then we can do searches on ranges of data? Unfortunately it doesn't work - you get an ora-06502 error just like you do when using the pre-query trigger. For the situation in the original thread you would have to use a 'default where'.

  • Photoshop CC 2014 hangs for nearly 15 seconds when using Layer Group Layers or Layer Palette Group from Layers commands.

    Photoshop hangs for nearly 15 seconds when using Layer > Group Layers or Layer Palette > Group from Layers commands. NOT on creating new group and creating layers and drag-n-dropping layers into group manually in Layer Palette. Got a UI design file with nearly 800 layers and lot of groups. This doesn't occur in smaller files. Using OS X Mavericks, Photoshop CC 2014.2.2, Mid 2014 15-inch Retina Macbook Pro.
    I understand that the solution would be just to cut the file into smaller files and design each UI view in a separate file but that would be painful. And it does not seem to be a very hard task to just group layers.

    Does the document also have a lot of layer comps?
    And can you post that document or send me a copy of it so we can see exactly why it is hanging?

  • Support for safety camera locations when using off...

    I've seen people manually post the file (as text) that you can put in the relevant folder on your phone's data card - but is there any ongoing support for safety camera updates when using your phone's mapping / sat nav offline (ie no data usage)?

    Jaff0 wrote:
    Doesn't seem like there's any option through the PC map loader program, so the only option seems to be if anybody has posted the file - which may not always happen?
    Safetyspots are not updated that often and I am sure someone on the forum would try to help you out if you asked.
    Happy to have helped forum with a Support Ratio = 42.5

  • How do you set up a password for a wireless network when using an Airport Extreme?

    How do you set up a password for a wireless network when using an Airport Extreme wireless router?

    Thanks for the updated information.
    Open Macintosh HD > Applications > Utilities > AirPort Utility
    Click on the AirPort Extreme icon, then click Manual Setup
    Click the Wireless tab below the row of icons
    Check to make sure that the setting for Wireless Security reads either WPA2 Personal or WPA/WPA2 Personal
    Enter a Wireless Password and Verify Password
    Click Update to save any changes and wait a full minute for the AirPort Etreme to restart

  • I am using outlook express for my mail. When using internet explorer on PC I could set it up so I could simultaneously see all my inboxes, the mail details and a message preview. Can I do this  on my Mac?

    I am using outlook express for my mail. When using internet explorer on PC I could set it up so I could simultaneously see all my inboxes, the mail details and a message preview. Can I do this  on my Mac?

    About accessing using a browser: I can get in using Firefox or Safari, butI cant set the page up to see all my inboxes at the same time (so I can file emails appropriately) or get a preview to save opening every mail

  • Error "Object refernce not set" when using http context in Eventreceiver for Document Library,

    Hi,
    Httpcontext returning null values when I used in item adding event of document library.
    I have a document set home page which has document set properties(by default) and one OOTB document library is placed in the same page.When user clicking on upload documents in the ribbon I need to read the document set properties.
    when uploading the docs if I pass the Hardcoded item id of the document set I am getting the values of the document set in the item added event.
    now the problem, i have the id in the query string if i want to read the query string value using httpcontext in the itemadding event and pass it to item added event using httpruntime it is throwing "object reference error" .
    if any body has any solution/workaround how to read the context in the document library event receiver,please help me out.
    Thanks ,G1

    Hi,
    Did you use the HttpContext.Current method to get the current context?
    You can use the HttpContext.Current to check whether it works.
    There is a similar thread for your reference.
    http://stackoverflow.com/questions/1601352/how-to-obtain-the-httpcontext-in-event-handler
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • Getting ZVAT Error for some items

    We are getting ZVAT errors for some QC number & line items..
    Please provide the cause.

    Hi,
    I hope you have created ZCST and ZVAT by copying JIN6 & JIN7. Also in V/06 against the above two
    condition types, ensure that "D" is assigned to Condition Class and Condition Category.
    Go to V/08, select your pricing procedure and check whether you could see any of the
    following condition types
    a) JCST or JIN1
    b) JLST or JIN2
    Subsequent to introduction of VAT system in India, both JIN1 & JIN2 were replaced with
    JIN6 & JIN7. May be, you would have copied JCST and JLST. Nevertheless, as I already mentioned,
    you should check in V/06 for Condition Class and Condition Category.
    follow this path -
    SPRO Logistics General - Tax on goods movement - India - Basic settings -
    Determination of Excise duty - Condition based excise determination -
    Assign tax code to company code.
    There maintain the tax code to company code. Also  mention the tax code for the above condition type in FV11.
    rgds
    Raj
    Edited by: RAJEEV SHARMA on Aug 20, 2010 5:53 PM

  • Error while importing Item MAster Data using DTW

    Hi,
    when we are importing item master data using items template
    it is giving error.
    Error:":connected value 1 was not found "
    can any one send the oitems template that is working fine wthout any error.
    Thanks,
    Neetu

    You cannot import  data prepration templates>>Testcase1_Test Data for Import function>Oitems directly.
    You will have to do certain prerequisites like setting CommissionGroup, CommissionPercent, CommissionSum,CustomsGroupCode etc., in SAP before importing Items.
    So I would like you to try out with minimum fields in the template and import. After understanding, you can import the required fields.
    I suggest you to use the template from "C:\Program Files\SAP\Data Transfer Workbench\Templates\Templates\oItems"

  • Error in Acrobat 9.0 when using png prediction for flatedecode filter

    Hi,
    I am creating a PDF using png prdiction and Acrobat 9.0 shows the following error: "insufficient data for an image". The same PDF doesn't show error when using Acrobat 7.0 or any other application to view it. A typical code is as following:
    "10 0 obj <</Length 7100038/Filter FlateDecode/DecodeParms<</BitsPerComponenet 8/Colors 4/columns 1103/Rows 1000/Predictor 15>>....etc."
    Does anyone have idea what can be the problem & how can I solve it???
    Thanks
    Ilana Keydar

    Attached is another PDF which I have added png prediction to the flatedecode
    filter of the images in order to get better compression. This file can't be
    open at all using Acrobat 9.0, but can be viewed using other PDF tools.
    I have also uploaded another PDF to the forum.
    I hope you can help me
    Ilana

  • Po number as assignment number for each item in MIR4 using substitution

    Hi All,
    Using substitution rule in GGB1 iam getting assignment number as PO number only for GL documents.
    But i need the same PO number as assignment number for cleared item documents...
    iam getting YYYYMMDD field as assignment number for each line item....but i need PO number...
    how can i achieve it...
    pls help experts...
    Regards
    Ram
    problem solved
    Edited by: gajeramesh on Feb 3, 2010 2:25 PM

    Hi,
    After creating the items you can write your own text upload program to upload the item texts. Note it cant be uploaded through BAPI or BDC.
    Search the forum for SAVE_TEXT FM, you will get lots of examples for this.
    Also Read the FM documentation for the above FM in SE37.
    Regards
    Karthik D

  • Create Multiple tasks for Single Item in List using state machine workflow in sharepoint

    Hi,
    I want to create multiple create tasks for Single Item in List based on Assigned to column using state machine Workflow through visual studio
    Here Assigned to column allows multiple users. so i have to create task for every user based on column .
    I'm trying for this but i didn't got any solution
    Please provide solution for this.

    Hi,
    According to your post, my understanding is that you wanted to allow multiple users to approve.
    There are some articles about creating parallel tasks in state machine workflow, you can have a look at them.
    http://www.codeproject.com/Articles/477849/Create-Parallel-Task-in-State-Machine-Workflow-in
    http://msdn.microsoft.com/en-us/library/office/hh128697(v=office.14).aspx
    http://social.technet.microsoft.com/Forums/office/en-US/b16ee858-4360-479a-a686-4ee35b7be9db/sharepoint-2010-workflow-creating-multiple-tasks?forum=sharepointdevelopmentprevious
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Error while adding items to cart using oracle.apps.ibe.shoppingcart.list.ShopList.saveQuoteFromListLines API

    Hello,
    I am getting the below error message when I try to add line items to cart using oracle.apps.ibe.shoppingcart.list.ShopList.saveQuoteFromListLines API.
    ORA-01403: no data found in Package IBE_Shop_List_PVT Procedure Save_Quote_From_List_Items
    This is the underlying procedure/package getting called:  IBE_Shop_List_Wrapper_PVT.Save_Quote_From_List_Items
    Please help me in resolving this issue.
    Thanks in advance!

    L S P.. wrote:
    Hi,
    Actually that notes says about invalid objects in ASO and IBE objects.
    But i couldn't found any invalid objects. Also i was cleared cache using functional administrator also.
    But still am getting this error.
    Please help on this.. It is on critical.Please log a SR if the doc did not help.
    Thanks,
    Hussein

  • Important: Item Disappears form Item Dashboard when used in Initiative

    Hello All,
    I have one urgent question. I am seeing one strange thing. When a PPM Item is created and lets say this Item has a role A with 'Write' access on it. When I log in as Role A, I can see the PPM Item on the Item Dashboard. But the strange thing is when an Initiative is created by Role B ( this Initiative has both 'Write' access for roles B and role A) and the above PPM Item is added. Then when I log in as Role A, I cant see the PPM item on Item Dashboard. To see the PPM Item as Role A, I have to go to Initiative first and then see added items and there I can see the above PPM Item but not directly from Item Dashboard. Can someone throw some light as why PPM item disappears from Item dashboard for Role A, even when Role A has write access on the PPM Item, after item is used in a initiative.
    Thanks,
    Sachin

    Hello Sachin,
    Implement SAP Note 1649142 and retest.
    Regards,
    Brendan

  • Error in begining a session when using UTF16 mode in OCIEnvNlsCtreate

    I wrote this code :
    OCIEnv* envhp;
    OCIError* errhp;
    OCIServer* srvhp;
    OCISvcCtx* svchp;
    OCISession* usrhp;
    envhp = (OCIEnv *) 0;
    errhp = (OCIError *) 0;
    srvhp = (OCIServer *) 0;
    svchp = (OCISvcCtx *) 0;
    usrhp = (OCISession *) 0;
    int mode = OCI_DEFAULT;
    char* dblink=/* DBLINK */;
         sword status;
    OCIEnvNlsCreate ( &envhp, (ub4) mode, (dvoid *)0,(dvoid*(*)(dvoid ctxp, size_t size))0,(dvoid(*)(dvoid ctxp, dvoid memptr, size_t newsize))0,(dvoid (*)(dvoid ctxp, dvoid memptr))0,(size_t)0, (void **)0, (ub2)OCI_UTF16ID, (ub2)OCI_UTF16ID);
    OCIHandleAlloc((dvoid*)envhp, (dvoid**)&errhp, (ub4)OCI_HTYPE_ERROR,(size_t)0, (dvoid**)0);
    OCIHandleAlloc((dvoid*)envhp, (dvoid**)&srvhp, (ub4)OCI_HTYPE_SERVER,(size_t)0, (dvoid**)0);
    status = OCIServerAttach(srvhp, errhp, (text*)dblink,(sb4)strlen(dblink), (ub4)OCI_DEFAULT);
    if (status != OCI_SUCCESS)
    return 0;
    char username = /username*/;
    char password = /password*/;
    OCIHandleAlloc((dvoid*)envhp, (dvoid**)&svchp, (ub4)OCI_HTYPE_SVCCTX,(size_t)0, (dvoid**)0);
    OCIAttrSet((dvoid*)svchp, (ub4)OCI_HTYPE_SVCCTX, (dvoid*)srvhp, (ub4)0,(ub4)OCI_ATTR_SERVER, errhp);
    OCIHandleAlloc((dvoid*)envhp, (dvoid**)&usrhp, (ub4)OCI_HTYPE_SESSION,(size_t)0, (dvoid**)0);
    OCIAttrSet((dvoid*)usrhp, (ub4)OCI_HTYPE_SESSION, (dvoid*)username,(ub4)strlen(username), (ub4)OCI_ATTR_USERNAME, errhp);
    OCIAttrSet((dvoid*)usrhp, (ub4)OCI_HTYPE_SESSION, (dvoid*)password,(ub4)strlen(password), (ub4)OCI_ATTR_PASSWORD, errhp);
    status = OCISessionBegin(svchp, errhp, usrhp, OCI_CRED_RDBMS, (ub4)OCI_DEFAULT);
    When I use OCI_UTF16ID in OCIEnvNlsCreate it gives me an error in OCISessionBegin. But when I use 871(utf8) instead it works properly. Why does this happen? How can I work whit OCI_UTF16ID?

    Re: OCIObjectSetAttr() and UTF16 environnement might be of interest, even though it's a little different. Still relates to UTF16 though. --DD                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for