Re: library package – load stylesheet s into XQuery?
Julian Jarosch <[email protected]> Mon, 24 Jun 2024 13:47:18 +0200
| Newsgroups | gmane.text.xml.exist |
|---|---|
| Message-ID | <[email protected]> |
Dear Jean-Paul,
Good idea! But that function evaluates to the collection of the XQuery
which imports the library module. E.g. I’m testing from a script in
/db/xquery which imports my library. I’ve inserted
system:get-module-load-path() into the library but still get /db/xquery
from the testing script.
Nevertheless, rubber ducking this with you got me thinking about this
section of the documentation
https://exist-db.org/exist/apps/doc/repo#considerations
I adapted the documented code snippet into
util:collection-name(collection('/db/system/repo')//expath:package[@name ="http://www.digitale-akademie.de/cmiferator"])
which works for me! It’s a bit inelegant to hard-code /db/system/repo,
but repo:get-root() gives me /db/apps. Perhaps I’ll get around to
optimizing that. For now, I think I’ll test what I’ve already got.
Thanks again!
Best,
Julian
Am 24.06.24 um 13:12 schrieb Jean-Paul Rehr:
> Dear Julian, understood.
>
> >Perhaps there is a programmatic way to obtain the current package
> base path (/db/system/repo/cmiferator-0.0.3) and use that for loading
> the stylesheet.
>
> You can dynamically get the path of the module from
> system:get-module-load-path() and parse the path into the string
> needed to build your resource path for the XLST file.
>
> Best,
> JPR
>
>
>
> On Mon, Jun 24, 2024 at 12:01 PM Julian Jarosch
> <[email protected]> wrote:
>
> Dear Jean-Paul,
>
> Thanks! Yes and no – yes, a library module, but within a package
> that is exclusively declared as a library. See the table with
> types of packages in this section:
> https://exist-db.org/exist/apps/doc/repo#sect-repoxml
>
> “Library package” with type = library and /no target specified/
> was what I was going for, so far.
>
> This means that the package is not deployed into the /db/apps
> collection. Instead it lives in /db/system/repo. Its collection
> name includes the version number. Currently the full path would be
> /db/system/repo/cmiferator-0.0.3/content/CMIF-base.xsl, but this
> will obviously change with the version number.
>
> Perhaps there is a programmatic way to obtain the current package
> base path (/db/system/repo/cmiferator-0.0.3) and use that for
> loading the stylesheet.
>
> Otherwise, I take your point and will consider setting a target
> where to deploy the package within the database
> (/db/apps/cmiferator) and use a fixed, complete resource path for
> loading the stylesheets. (It’s just that initially the library
> package concept seemed a good fit for what I try to achieve – make
> a few XQuery functions available database-wide.)
>
> Best,
> Julian
>
> Am 24.06.24 um 11:43 schrieb Jean-Paul Rehr:
>> Dear Julian,
>>
>> >Is it even possible to include XSLTs in a library package in a
>> manner that they can be loaded into XQuery?
>>
>> I assume by "library package" you mean library module? I do this
>> all the time without an issue. It's just another XML document.
>>
>> However I have a doubt about this path:
>>
>> >doc('./CMIF-base.xsl')
>>
>> Have you tested this with the full explicit path to the document?
>> e.g. "/db/apps/myapp/CMIF-base.xsl"
>>
>> Cheers,
>> JPR
>>
>>
>> On Mon, Jun 24, 2024 at 11:35 AM Julian Jarosch
>> <[email protected]> wrote:
>>
>> Hello everyone,
>>
>> I’m trying to use XSLT stylesheets in an XQuery module in a
>> library package, along the lines of (simplified example):
>>
>> declare variable $template := doc('./CMIF-base.xsl');
>>
>> The current actual code is here:
>>
>> https://github.com/digicademy/cmiferator/blob/78b2725bf9fcc163fc48df0a96c436fadeefcef6/library-package/content/cmiferator.xqm#L25
>>
>> I had successfully tested this as an XQuery module written
>> directly in eXist/eXide. It stopped working when I installed
>> it as a library package, as far as I can tell.
>>
>> By “stopped working” I mean that the variable which is
>> supposed to contain the stylesheet document ($template in the
>> example) remains empty and the transform:transform() function
>> fails because of a missing stylesheet argument.
>>
>> Currently, it seems to me that the cause is with the library
>> package? Is it even possible to include XSLTs in a library
>> package in a manner that they can be loaded into XQuery?
>>
>> Thanks for any guidance – presumably for pointing out an
>> egregious oversight on my end :-)
>>
>> Kind regards,
>> Julian
>>
>> _______________________________________________
>> Exist-open mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/exist-open
>>
> _______________________________________________
> Exist-open mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/exist-open
>
>
>
> _______________________________________________
> Exist-open mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/exist-open
_______________________________________________
Exist-open mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/exist-open