This discussion is archived
2 Replies Latest reply: Oct 23, 2013 4:11 AM by RokoA RSS

0 result returned for query "collection ('exampledata.dbxml')/article

RokoA Newbie
Currently Being Moderated

I  using  BDB XML I create a container called Exampledata.dbxml using java API. using a separate program I put my sigmodRecord.xml  file into the container. I then wrote another program (see the program below) to test my Query

where Query =  "collection ('Exampledata.dbxml')/article"  but dont know why i always have

                                                  0 result returned for query "collection ('exampledata.dbxml')/article  if  the program is run. Pls can anybody help me?




package xmldbdemo;

 

import com.sleepycat.db.Environment;

import com.sleepycat.dbxml.*;

import dbxml.gettingStarted.myDbEnv;

import java.io.File;

public class simpleQuery3 {

    public static void main (String[] args) throws Throwable  {

 

     String theContainer = "Exampledata.dbxml";

 

      File path2DbEnv = new File("c:/myJavaProgs/examplesEnvironment");

     if (path2DbEnv == null || ! path2DbEnv.isDirectory()) {

           System.out.println("Bad file name");

      System.exit( -1 );

     }

 

 

  myDbEnv env = null;

  XmlContainer openedContainer = null;

 

     env = new myDbEnv(path2DbEnv);

 

            Environment enviro = env.getEnvironment();

 

 

     // create xmlmanager

       XmlManagerConfig myManagerConf = new  XmlManagerConfig();

       myManagerConf.setAdoptEnvironment(true);

       myManagerConf.setAllowExternalAccess(true);

       XmlManager myManager = new XmlManager  (enviro, myManagerConf);

 

 

   // XmlManager myManager = new XmlManager();

    XmlContainerConfig myContainerConf = new  XmlContainerConfig();

 

         

    XmlContainer myContainer = myManager.openContainer( theContainer, myContainerConf);

    XmlQueryContext myContext =  myManager.createQueryContext();

 

 

    String myQuery = "collection('Exampledata.dbxml')/article";

    XmlResults myResults = myManager.query(myQuery, myContext, null);

    XmlValue myValue = myResults.next();

    while (myValue != null){

     XmlDocument myDocument = myValue.asDocument();

     String name  = myDocument.getName();

     System.out.println(name);

 

    }

           

    }

    }

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points