Wyatt,
This should be considered a bug. The underlying
cause is that there is a weakness in the XDBC protocol
(XCC speaks the same protocol as XDBC). There is a
presumption in XDBC that node = element and this means
that information about the specific node type is not
returned by the server (except for text() and binary(),
which are handled differently than other nodes).
In XDBC, all nodes (element, attribute, etc) have
the same Java type (XDBCSchemaTypes.Node). In XCC,
there are Java types for all the XDM node types. This
means that all node instances will be a concrete
type (element(), attribute(), etc) rather than the
abstract node() type.
Sadly, resource constraints prevented the needed
server-side changes to implement an improved protocol
to fully specify concrete node types. To be consistent
with the Java object model XCC assumes nodes are elements,
which is the same assumption that exists in XDBC.
You can still obtain the value of attributes by
calling AsString() on the XdmItem instance. The
AsString() method should do the right thing for all
node types. If you want to convert an element to
a DOM, those methods may throw an exception if the
item is not actually an element().
We plan to implement the protocol improvements in
a future release. At that time, the full complement
of Java node types will map to the XDM types as expected.
On Aug 14, 2006, at 7:54 PM, Wyatt wrote:
Greetings all,
I've been playing with the .NET version of the XCC package and have
run into an obstacle I can't seem to surmount. Maybe a bug - more
likely my own ignorance...
I'm trying to write a C# (VS 2005) function that utilizes XCC to
execute an arbitrary XQuery and return a string of well-formed
XML. All is well if the XQuery happens to return a single element,
but I'm running into trouble post processing it if it is not. It
appears that NodeType.ToString() always returns "element()"
I've been using the XdmItem as so...
//--
private string ProcessResults(ResultSequence rs) {
StringBuilder sb = new StringBuilder();
while (rs.HasNext()) {
XdmItem xi = rs.Next().Item;
if (xi.ItemType.Node) {
sb.AppendLine(((NodeType)xi.ItemType).ToString());
}
else if (xi.ItemType.Atomic) {
sb.AppendLine(((AtomicType)xi.ItemType).ToString());
}
}
return sb.ToString();
}
//--
The XdmItem.ItemType seems to accurately resolve what is a Node and
what is an Atomic, and ToString() correctly returns "xs:string" for
an atomic string (didn't try any others), BUT when it is a Node
ToString() always returns "element()" even it is an attribute
node??? I'd have thought it would return "attribute()"?
Any help would be much appreciated.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
---
Ron Hitchens [EMAIL PROTECTED] 650-655-2351
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general