One thing that I do is to use Xml Serializable Attributes to model the
classObject and write utility class that serializes the value from Xml
or string to an Object and vice versa. This can usually be a bridge
layer between your data access layer and Business logic layer.
XML --> POJO --> BusObject --> AppTier. |
ML <-- POJO <-- BusObject <-- AppTier. <--
IE
[XmlRoot(ElementName="my-object", Namespace="urn:my-namespace")]
Public class MyObject
{
[XmlAttribute(AttributeName="id", Order=10)]
public string id{get{}set{}}
[XmlElement(ElementName="",Order=20)]
public string apple{get{}set{}}
[XmlArray("my-children")]
[XmlArrayItem("child")]
public MyChild[] Children{get{} set{}}
}
<my-object xmlns="urn:my-namespace" id="1000">
<apple></apple>
<my-children>
<child id=""/>
<child id=""/>
</my-children>
</my-object>
A few notes about serialization
* Make sure you use the order attribute constructor if round
tripping serializing. .NET will need this to properly serialize your
values, since it usually wants the nodes in a certain order.
* Make sure your string properties do not have child nodes.
(highlighting nodes or Html) This will barf the serializer. If
necessary use IXmlSerializable interface to overcome this issue or use
xdmp:quote to quote the content.
* Getters and setters must be public. So you have to use a
little Plain Old C# Objects. Serialization needs both values.
* If using .net 3.5 try using DataContractAttribute instead of
Xml.Serialization
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Friday, June 13, 2008 3:00 PM
To: [email protected]
Subject: General Digest, Vol 48, Issue 4
Send General mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://xqzone.com/mailman/listinfo/general
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
You can reach the person managing the list at
[EMAIL PROTECTED]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of General digest..."
Today's Topics:
1. Re: Pass a Node datatype from .Net using XCC API to Marklogic
XDBC service (Eoin MacDonncha)
2. RE: Re: Pass a Node datatype from .Net usingXCC API to
Marklogic XDBC service (Frank Sanders)
----------------------------------------------------------------------
Message: 1
Date: Fri, 13 Jun 2008 14:21:32 +0100
From: "Eoin MacDonncha" <[EMAIL PROTECTED]>
Subject: [MarkLogic Dev General] Re: Pass a Node datatype from .Net
using XCC API to Marklogic XDBC service
To: <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="utf-8"
Hello,
I was wondering does anyone have any experience or examples of how an
.Net object (or Java, it may help) can be passed to XQuery module using
the XCC API.
My code at the mode serializes the .Net object to a string and passes it
to XQuery as a ValueType.XS_STRING.
Is it possible to do something like convert the .Net object to an
XPathDocument object and pass it as a ValueType.NODE datatype. I've
tried this but when I try and set the variable i.e.
request.SetNewVariable(xName, xValue); I get an error
"Specified argument was out of the range of valid values.\r\nParameter
name: String, org.w3c.dom.Element or InputStream value required to
construct element()"
Any ideas would be great.
Eoin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://xqzone.marklogic.com/pipermail/general/attachments/20080613/24ecd
ae0/attachment-0001.html
------------------------------
Message: 2
Date: Fri, 13 Jun 2008 08:41:28 -0700
From: "Frank Sanders" <[EMAIL PROTECTED]>
Subject: RE: [MarkLogic Dev General] Re: Pass a Node datatype from
.Net usingXCC API to Marklogic XDBC service
To: "Eoin MacDonncha" <[EMAIL PROTECTED]>, "General Mark
Logic
Developer Discussion" <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="utf-8"
Skipped content of type multipart/alternative-------------- next part
--------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4245 bytes
Desc: not available
Url :
http://xqzone.marklogic.com/pipermail/general/attachments/20080613/72380
b2a/smime-0001.bin
------------------------------
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
End of General Digest, Vol 48, Issue 4
**************************************
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general