From: Martin H. <mh...@uv...> - 2013-10-23 15:16:40
|
My simple test-case works perfectly: --------- xquery version "3.0"; declare default element namespace "http://www.w3.org/1999/xhtml"; import module namespace util="http://exist-db.org/xquery/util"; declare namespace xi="http://www.w3.org/2001/XInclude"; import module namespace xmldb="http://exist-db.org/xquery/xmldb"; let $testContents := <html> <body> <p>Para 1</p> <p>Para 2</p> <xi:include href="http://hotpot.uvic.ca/"> <xi:fallback><div xmlns="http://www.w3.org/1999/xhtml">Unable to find xincluded content.</div></xi:fallback> </xi:include> </body> </html>, $storedDoc := xmldb:store('/db/test/', 'text.xml', $testContents, 'application/xml'), $test2 := <html> <body> <xi:include href="{$storedDoc}"> <xi:fallback><div xmlns="http://www.w3.org/1999/xhtml">Unable to find xincluded content.</div></xi:fallback> </xi:include> </body> </html>, $test3 := util:expand($test2, "enable-xincludes=yes") return $test3//p -------- Result: <p xmlns="http://www.w3.org/1999/xhtml">Para 1</p> <p xmlns="http://www.w3.org/1999/xhtml">Para 2</p> So there's obviously some complicating factor in my application. I suspect it's something to do with using relative paths; the relative path in the href attribute in the XInclude is relative to the containing document, but perhaps the execution context is the location of the XQuery document that's doing the work. Cheers, Martin On 13-10-23 05:46 AM, Martin Holmes wrote: > Hi Jens, > > That does work for me -- thanks for pointing out the issues. I should > have noticed the badly-linked dtd, especially. > > So now I have to figure out why it's not working when I try to expand an > XInclude with a local file. I worked around it in my project, but I'd > still like to figure the problem out. I'll try to post a test case today. > > Cheers, > Martin > > On 13-10-23 01:06 AM, Jens Østergaard Petersen wrote: >> Hi Martin, >> >> I think there are a number of problems. >> >> First, it would be safest for the the @href to point to a definite resource, and "http://hotpot.uvic.ca" actually points to "http://hotpot.uvic.ca/index.php". That's no error, though. >> >> Second, the document referenced should be wellformed and expandable XML, but I get the following errors when I store this page and try to reference it: >> >> First error: >> >> exerr:ERROR XInclude: failed to read document at URI: http://tls.uni-hd.de/hotpot.xml: /Applications/exist_dev/xhtml11.dtd (No such file or directory) [at line 16, column 14] >> >> So I would remove "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">". >> >> You get the same error when you try to run >> >> xquery version "3.0"; >> >> declare default element namespace "http://www.w3.org/1999/xhtml"; >> declare namespace util="http://exist-db.org/xquery/util"; >> declare namespace xi="http://www.w3.org/2001/XInclude"; >> >> let $test := <html> >> <body> >> <xi:include href="http://hotpot.uvic.ca" xpointer="xpointer(//h3)"/> >> </body> >> </html> >> let $test := util:expand($test) >> return $test >> >> With that error fixed comes the Second error: >> >> exerr:ERROR The entity "nbsp" was referenced, but not declared. [at line 16, column 14] >> >> So I would resolve " " and perhaps run tidy with xml output to be sure. Basically, I think this means that you cannot xinclude run-of-the-mill html. >> >> Third, you are trying to include too much contents. >> >> 23 Oct 2013 09:48:04,065 [eXistThread-90] WARN (XQueryWatchDog.java [proceed]:149) - Query exceeded predefined output-size-limit (1,000,000) for document fragments: { >> >> So don't try to include all divs. >> >> I have placed a sanitized and obfuscated hotpot doc at <http://tls.uni-hd.de/hotpot.xml>. Of course, I will pull it down immediately. >> >> Try running >> >> xquery version "3.0"; >> >> declare default element namespace "http://www.w3.org/1999/xhtml"; >> declare namespace util="http://exist-db.org/xquery/util"; >> declare namespace xi="http://www.w3.org/2001/XInclude"; >> >> let $test := <html> >> <body> >> <xi:include href="http://tls.uni-hd.de/hotpot.xml" xpointer="xpointer(//h3)"/> >> </body> >> </html> >> let $test := util:expand($test) >> return $test >> >> >> Jens >> >> PS: I was a happy user of Hot Potatoes about a decade ago. >> >> On Oct 23, 2013, at 1:46 AM, Martin Holmes <mh...@uv...> wrote: >> >>> I've been struggling with XInclude, and as far as I can tell, >>> util:expand is failing to do XInclude expansion. Running this on eXist >>> 2.1 build date 20130924, only the fallback div is returned: >>> >>> ------------- >>> xquery version "3.0"; >>> >>> declare default element namespace "http://www.w3.org/1999/xhtml"; >>> declare namespace util="http://exist-db.org/xquery/util"; >>> declare namespace xi="http://www.w3.org/2001/XInclude"; >>> >>> let $test := >>> <html> >>> <body> >>> <xi:include href="http://hotpot.uvic.ca" parse="xml" >>> xpointer="xpointer(//div)"> >>> <xi:fallback><div xmlns="http://www.w3.org/1999/xhtml">Unable to find >>> xincluded content.</div></xi:fallback> >>> </xi:include> >>> </body> >>> </html>, >>> >>> $test2 := util:expand($test) >>> >>> return $test2//div >>> ----------- >>> >>> Can anyone see what I'm doing wrong here? The target document has >>> several div elements in the default namespace, and is valid. >>> >>> In my project, I'm actually trying to XInclude another document from the >>> db, and having the same bad results, but the example above should run as >>> a standalone. >>> >>> All help appreciated, >>> Martin >>> >>> >>> >>> On 13-08-19 04:46 AM, Loren Cahlander wrote: >>>> Try running util:expand($node as node()*) as node()* or util:expand($node as node()*, $serialization-parameters as xs:string) as node()*against your XML. It creates an in-memory copy of the passed node set, using the specified serialization options. By default, full-text match terms will be tagged with <exist:match> and XIncludes will be expanded. >>>> >>>> let $doc := util:expand(doc('W0014.xml')) >>>> >>>> >>>> >>>> On Aug 19, 2013, at 6:32 AM, Andreas Wagner <And...@em...> wrote: >>>> >>>>> Dear list, >>>>> >>>>> if I understand the documentation correctly, exist's xquery does not >>>>> "look inside" xincluded documents. I mean, where a TEI document >>>>> W0014.xml would contain: >>>>> >>>>> <text> >>>>> <group> >>>>> <xi:include href="W0014_Vol01.xml" xpointer="Vol1"/> >>>>> <xi:include href="W0014_Vol02.xml" xpointer="Vol2"/> >>>>> </group> >>>>> </text> >>>>> >>>>> and W0014_Vol01.xml in turn would contain: >>>>> <text xml:id="Vol1"> >>>>> <group> >>>>> <text xml:id="Vol1Lect1"> >>>>> <body> >>>>> <p>blabla</p> >>>>> </body> >>>>> </text> >>>>> <text xml:id="Vol1Lect2"> >>>>> <p>blehbleh</p> >>>>> </text> >>>>> </group> >>>>> </text> >>>>> >>>>> And now if W0014 were present as "currentWork" in the current model, and >>>>> I had an xquery with a FLWOR statement [1] using the xpath >>>>> >>>>> $model('currentWork')//tei:text/@xml:id >>>>> >>>>> , it would not find anything, for the text elements in the main document >>>>> do not possess xml:id attributes and those of the xincluded documents >>>>> are not seen by the xquery engine. >>>>> >>>>> First question: Did I understand this correctly? >>>>> >>>>> Followup-questions: a) Is it in the roadmap somewhere that this will be >>>>> supported? >>>>> b) eXist docs state: "You therefore cannot query across XIncludes - >>>>> unless you create your own code (e.g. an XQuery function) for it." How >>>>> would I go about this - or, being an xquery novice, should I be trying >>>>> this at all? Or perhaps anyone already has a function doing similar >>>>> stuff? >>>>> >>>>> Thanks and best regards, >>>>> >>>>> Andreas >>>>> >>>>> >>>>> >>>>> >>>>> [1] For completeness's sake here is the whole function I have in the >>>>> works: >>>>> >>>>> declare function app:links($node as node(), $model as map(*)) { >>>>> let $work := <a href="data/{$model('currentWork')/@xml:id || '.xml'}">{$model('currentWork')/@xml:id/string()}</a> >>>>> let $parts := for $part in $model('currentWork')//tei:text/@xml:id >>>>> return (" ", <a href="data/{$model('currentWork')/@xml:id || '.xml#' || $part/string()}">{$part/string()}</a>) >>>>> let $sep := if ($model('currentWork')//tei:text/@xml:id) then >>>>> <text>: </text> >>>>> else >>>>> <text/> >>>>> return ($work, $sep, $parts) >>>>> }; >>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Dr. Andreas Wagner >>>>> Project "The School of Salamanca" >>>>> Academy of Sciences and Literature, Mainz >>>>> and Institute of Philosophy >>>>> Goethe University Frankfurt >>>>> http://salamanca.adwmainz.de >>>>> >>>>> Grüneburgplatz 1 (Pf 116, R. 2.455) >>>>> 60629 Frankfurt am Main >>>>> Tel. +49 (0)69/798-32774 >>>>> Fax +49 (0)69/798-32794 >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Get 100% visibility into Java/.NET code with AppDynamics Lite! >>>>> It's a free troubleshooting tool designed for production. >>>>> Get down to code-level detail for bottlenecks, with <2% overhead. >>>>> Download for free and get started troubleshooting in minutes. >>>>> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk >>>>> _______________________________________________ >>>>> Exist-open mailing list >>>>> Exi...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/exist-open >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Get 100% visibility into Java/.NET code with AppDynamics Lite! >>>> It's a free troubleshooting tool designed for production. >>>> Get down to code-level detail for bottlenecks, with <2% overhead. >>>> Download for free and get started troubleshooting in minutes. >>>> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk >>>> >>> >>> >>> ------------------------------------------------------------------------------ >>> October Webinars: Code for Performance >>> Free Intel webinars can help you accelerate application performance. >>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from >>> the latest Intel processors and coprocessors. See abstracts and register > >>> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk >>> _______________________________________________ >>> Exist-open mailing list >>> Exi...@li... >>> https://lists.sourceforge.net/lists/listinfo/exist-open >> >> >> ------------------------------------------------------------------------------ >> October Webinars: Code for Performance >> Free Intel webinars can help you accelerate application performance. >> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from >> the latest Intel processors and coprocessors. See abstracts and register > >> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk >> > > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > _______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open > |