xml-xindice-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jcplerm" <jcpl...@ameritech.net>
Subject Re: How to get rid of namespace? (Xindice 1.1b2)
Date Sun, 03 Aug 2003 04:01:59 GMT
I managed to get rid of those "xmlns:src" attributes by modifying the method "expandSource"
of class
org.apache.xindice.xml.dom.ElementImpl.java by removing the body as in:


    public void expandSource() {
    }

Then I re-built Xindice.

Now the result from the database is clean, but the root element of each document contained
in the result set no longer has the "src:key" attribute:


                ...
                <elem1 id="k2">
                        <type>AK</type>
                        <elem2>
                                <elem3 id="c">
                                        <elem4>A</elem4>
                                </elem3>
                                <elem3 id="b">
                                        <elem4>D</elem4>
                                </elem3>
                        </elem2>
                </elem1>
                ...

It's easy to see this is not the right solution... Under certain circumstances the "src:key"
attribute is relevant.

How can I get rid of the "xmlns:src" in all non-root elements of documents in a result set
from a Xindice 1.1b2 server
(but, again, keeping them in the root elements)?

Thanks,

jlerm

  ----- Original Message ----- 
  From: jcplerm 
  To: xindice-users@xml.apache.org 
  Sent: Saturday, August 02, 2003 10:12 PM
  Subject: How to get rid of namespace? (Xindice 1.1b2)


  I was able to run a query against a collection using the CollectionImpl class.

  I get each and every element in the result set tagged with a namespace, like:

                  ...
                  <elem1 id="k2" xmlns:src="http://xml.apache.org/xindice/Query">
                          <type xmlns:src="http://xml.apache.org/xindice/Query">AK</type>
                          <elem2 xmlns:src="http://xml.apache.org/xindice/Query">
                                  <elem3 id="c" xmlns:src="http://xml.apache.org/xindice/Query">
                                          <elem4 xmlns:src="http://xml.apache.org/xindice/Query">A</elem4>
                                  </elem3>
                                  <elem3 id="b" xmlns:src="http://xml.apache.org/xindice/Query">
                                          <elem4 xmlns:src="http://xml.apache.org/xindice/Query">D</elem4>
                                  </elem3>
                          </elem2>
                  </elem1>
                  ...

  I actually made another version of CollectionImpl.query(), which returns the content from
the server without building a resource set as in:


        public String queryAsString(String name, String queryLang, String query, Hashtable
nsMap) throws XMLDBException {

            checkOpen();
            try {

                Hashtable params = new Hashtable();
                params.put(RPCDefaultMessage.COLLECTION, collPath);
                params.put(RPCDefaultMessage.TYPE, queryLang);
                params.put(RPCDefaultMessage.NAMESPACES, nsMap);
                params.put(RPCDefaultMessage.QUERY, query);

                if (name != null) {

                    params.put(RPCDefaultMessage.NAME, name);
                }

                String result = (String) runRemoteCommand("Query", params);
                
                return result;
            } catch (Exception e) {

                throw FaultCodes.createXMLDBException(FaultCodes.QRY_PROCESSING_ERROR, "Query
error", e);
            }
        }
  I then invoke it like:


     String rs=null;
     try {
      rs = coll.queryAsString(null,"XPath","/entity",new Hashtable());
      System.out.println("RESULT===>>> " + rs);
     }
     catch (XMLDBException e) {
      System.out.println("XMLRPCTest.main(): query() failed: " + e.getMessage());
      e.printStackTrace();
     }
  Any ideas?

  Thanks,

  jlerm
Mime
View raw message