What is the source of your XML files? This points to the XML not 
being valid in the first place or you are not reading in the DOCTYPE 
declaration with its corresponding entity declarations. Minimally you 
should find a statement like this:

   '<!DOCTYPE root [<!ENTITY mdash "&#x2014;">]>';

or the doctype might reference an external text entity that then 
lists all the many different "standard" entity declarations that came 
from the SGML world.

..dan

At 06:42 AM 12/30/2011, you wrote:

>    Try this code, adjusting the name of your root
>node as needed.  Other entities could also be defined
>in the doc-type header.
>
>    This loads the XML first as text, prepends a doc-type
>header that defines the entity and then parses the result
>as XML.  This requires making an extra copy of the document
>in memory, so it could bump against memory limits if you
>do it in volume with lots of large documents.
>
>    Handy list of entity definitions here:
>http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
>
>
>xquery version '1.0-ml';
>
>declare variable $file-path := "/tmp/z.xml";   (: path of XML doc in 
>filesystem :)
>
>declare variable $document-uri := "/test/mydoc.xml";   (: URI to 
>insert it as in MarkLogic :)
>
>declare variable $load-options :=            (: force loading as 
>text, not as XML :)
>     <options xmlns="xdmp:document-get">
>       <format>text</format>
>     </options>;
>
>declare variable $doctype-decl as xs:string :=   (: adjust root node 
>name and add entities as needed :)
>    '<!DOCTYPE root [<!ENTITY mdash "&#x2014;">]>';
>
>let $doc-as-text := xdmp:document-get ($file-path, $load-options)
>let $doc-with-decl := fn:concat ($doctype-decl, $doc-as-text)
>let $doc := xdmp:unquote ($doc-with-decl)
>
>return xdmp:document-insert ($document-uri, $doc)
>
>
>On Dec 30, 2011, at 6:05 AM, John Zhong wrote:
>
> > Thanks for your quick answer, Harry.
> >
> > But how if I don't want to modify the original xml?
> >
> > Thanks,
> > John
> >
> > On Fri, Dec 30, 2011 at 1:59 PM, Harry B. <[email protected]> wrote:
> > Try using the numeric instead
> >
> > &#8211;
> >
> > I can't remember why, but this usually works.
> >
> > On Dec 29, 2011 10:53 PM, "John Zhong" <[email protected]> wrote:
> > Hi all,
> >
> > I am having problem to use the xdmp:document-get function to read 
> a xml with entiry reference &ndash; I want to know how to fix this 
> problem? I am using ML 5.0-1.2 version.
> >
> > [1.0-ml] XDMP-DOCENTITYREF: xdmp:document-get("D:\test.xml") -- 
> Invalid entity reference "ndash" at D:\test.xml line 231
> >
> > Thank you,
> > John
> >
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
> >
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
> >
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
>
>---
>Ron Hitchens {mailto:[email protected]}   Ronsoft Technologies
>      +44 7879 358 212 (voice)          http://www.ronsoft.com
>      +1 707 924 3878 (fax)              Bit Twiddling At Its Finest
>"No amount of belief establishes any fact." -Unknown
>
>
>
>
>_______________________________________________
>General mailing list
>[email protected]
>http://developer.marklogic.com/mailman/listinfo/general

---------------------------------------------------------------------------
Danny Vint

Panoramic Photography
http://www.dvint.com

voice: 619-938-3610
     

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to