[MarkLogic Dev General] Loading a document through XCC with the
Content object
Michael Blakeley
michael.blakeley at marklogic.com
Mon Jun 30 15:59:29 PDT 2008
Mattio,
Yes, the extra text node is probably just leading whitespace - you could
write a query to verify that.
string-to-codepoints(doc("/product/633504414890149643.xml")/text())
While it's probably harmless, I suspect that you're using an older
release of cq. The latest release has code designed to address this
issue (http://developer.marklogic.com/svn/cq/releases/).
-- Mike
Mattio Valentino wrote:
> Thanks for the quick reply, Michael. I tried:
>
> for $i in doc('/product/633504414890149643.xml')/node()
> return xdmp:describe($i)
>
> and got back:
>
> <results warning="more than one node">
> doc("/product/633504414890149643.xml")/text()
> doc("/product/633504414890149643.xml")/product
> </results>
>
> When I ran the same test on a document I loaded with
> xdmp:document-load I got back:
>
> <results warning="non-element node">doc("/lessons/LESSON1.xml")/book</results>
>
> So that extra text node is nothing to worry about? I checked the XML
> file being loaded through XCC and there doesn't seem to be anything
> unusual about it.
>
> On 6/30/08, Michael Blakeley <michael.blakeley at marklogic.com> wrote:
>> Mattio,
>>
>> I don't know much about C#, but I do know that the node-kind code in cq
>> isn't 100% reliable, especially if you're using an older release of cq.
>> Multiple nodes at the root level can produce misleading cq listings.
>>
>> Try this:
>>
>> for $i in doc('/product/633504414890149643.xml')/node()
>> return xdmp:describe($i)
>>
>> If the problem is in cq's node-kind code, you might see something like:
>>
>> doc('/product/633504414890149643.xml')/text()
>> doc('/product/633504414890149643.xml')/product
>>
>> (Guessing that your root element is named "product" - otherwise, replace
>> "product" with whatever your root element is called). But if there's a
>> problem with the document ingestion, you might see a text node by itself:
>>
>> doc('/product/633504414890149643.xml')/text()
>>
>> In that case, there's a problem with document ingestion, and your document
>> is arriving as serialized text, instead of XML.
>>
>> -- Mike
>>
>> Mattio Valentino wrote:
>>> I'm loading an XML file using XCC in C#. It's working fine, but I
>>> noticed one detail I'm not sure about.
>>>
>>> I'm loading the file with the following snippet:
>>>
>>> FileInfo file = new FileInfo(fileUri);
>>> ContentCreateOptions options = new ContentCreateOptions();
>>> options.Collections = new string[] { this.Collection };
>>> options.Format = DocumentFormat.Format.XML;
>>> Marklogic.Xcc.Content myDocument =
>>> ContentFactory.NewContent(this.Collection + "/" +
>> file.Name, file,
>>> options);
>>> mlSession.InsertContent(myDocument);
>>>
>>> The document loads fine and I can query it with cq fine.
>>>
>>> When I list all documents in cq using the link in the top left,
>>> documents I've loaded with xdmp:load or xdmp:document-load come up
>>> with something like:
>>>
>>> /product/GR3410.xml - element book
>>>
>>> But the documents I loaded with XCC come up with something like:
>>>
>>> /product/633504414890149643.xml - text
>>>
>>> Am I doing something wrong when I insert the document or is this
>>> nothing to worry about?
>>>
>>> Thanks,
>>> Mattio
>>> _______________________________________________
>>> General mailing list
>>> General at developer.marklogic.com
>>> http://xqzone.com/mailman/listinfo/general
>>>
>> _______________________________________________
>> General mailing list
>> General at developer.marklogic.com
>> http://xqzone.com/mailman/listinfo/general
>>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
More information about the General
mailing list