hi ...
I noticed that if I say this in XUpdate:

    <text>Tom &amp; Jerry</text>

and then use XPath to query the text, it comes back as this: "Tom "
(in other words it is truncated where I tried to get an ampersand.)

Is this a bug or is there some reason for handling entities this way?

Attached is a Java program which demonstrates this.  When I run this
program I get the following output (after adding line breaks):

<?xml version="1.0"?>
<newelement
xmlns:src="http://xml.apache.org/xindice/Query";
src:col="/db/pim"
src:key="0200a7c066658d72000000ed95df4fd5">tom </newelement>

It also happens while using the XML/RPC interface.

thanks,

        Jonathan
import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;
import java.io.FileReader;
import java.io.StringWriter;

// The database contents should initially look something like this:
//
// <?xml version="1.0" encoding="utf-8" ?>
// <user name="jhmark">
// </user>

public class testjava {
    public static void main(String[] args) throws Exception {
	Collection col = null;
	String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
	Class c = Class.forName(driver);
	
	Database database = (Database) c.newInstance();
	DatabaseManager.registerDatabase(database);
	col = DatabaseManager.getCollection("xmldb:xindice:///db/pim");
	
	FileReader fileReader = new FileReader("update.xml");
	StringWriter w = new StringWriter();
	XUpdateQueryService update_service =
	    (XUpdateQueryService)col.getService("XUpdateQueryService", "1.0");
	XPathQueryService query_service =
            (XPathQueryService) col.getService("XPathQueryService", "1.0");
	
	update_service.update(
"<X:modifications version=\"1.0\" xmlns:X=\"http://www.xmldb.org/xupdate\";>" +
"  <X:remove select=\"/[EMAIL PROTECTED]'jhmark']/newelement\" />" +
"</X:modifications>"
                              );

	update_service.update(
"<X:modifications version=\"1.0\" xmlns:X=\"http://www.xmldb.org/xupdate\";>" +
"<X:append select=\"/[EMAIL PROTECTED]'jhmark']\">" +
"<X:element name=\"newelement\">" +
"<X:text>tom &amp; jerry</X:text>" +
"</X:element>" +
"</X:append>" +
"</X:modifications>"
                              );

	ResourceSet resultSet = query_service.query("/[EMAIL PROTECTED]'jhmark']/newelement");
	ResourceIterator results = resultSet.getIterator();
	while (results.hasMoreResources()) {
            Resource res = results.nextResource();
            System.out.println((String) res.getContent());
	}
    }
}

Reply via email to