Same prefix, same functions, different namespace?
Friday, 8 July 2022 · 3 messages
GS
Graydon Saunders8 Jul 2022 01:19 #
Hello --
As part of a long and involved conversion process, the content starts in a lax version of the target vocabulary and proceeds to a strict version of the target vocabulary.
By local convention, the two vocabularies use the same namespace prefix but are not the same namespace and use different namespace URIs.
Ideally, I would be using the same test functions in a lot of cases, only changing the association for the prefix depending on the data.
So far as I know, there isn't any way to declare a namespace dynamically; I can't create a "test this content" module and tell it which namespace to use in some parameterized way, so I'm going to have to create two versions of the module despite the only difference being a namespace declaration.
Is that right, or is there a way to do this?
Thanks!
Graydon
LQ
Liam R. E. Quin8 Jul 2022 03:13 #
Quoted text · Graydon Saunders · 4 lines
On Thu, 2022-07-07 at 17:18 -0400, Graydon Saunders wrote: > > So far as I know, there isn't any way to declare a namespace > dynamically;
https://www.w3.org/TR/xquery-31/#id-computed-namespaces
may help?
You can pass a namespace node as a function parameter, too, at least in theory (i've never done it) :)
--
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org
G
Graydon8 Jul 2022 06:21 #
Quoted text · Graydon Saunders · 8 lines
On Thu, Jul 07, 2022 at 07:12:27PM -0400, Liam R. E. Quin scripsit: > On Thu, 2022-07-07 at 17:18 -0400, Graydon Saunders wrote: > > So far as I know, there isn't any way to declare a namespace > > dynamically; > > https://www.w3.org/TR/xquery-31/#id-computed-namespaces > > may help?
The thing I'm after is to be able to go
declare namespace prefix = $URI;
in a module prolog, and to be able set or pass a value for $URI when the
module is loaded so the prefix gets bound in the static context to
whatever is in $URI.I'm pretty sure there isn't a way to do that, but I've certainly been wrong before.
(The use case is handling versions of the same notional vocabulary with the same prefix; most of the tests I want to run apply to things like references and metadata which follow the same rules in the strict and lax versions of the vocabulary, so it would be nice not to duplicate the testing functions.)
Quoted text · Liam R. E. Quin · 2 lines
> You can pass a namespace node as a function parameter, too, at least in > theory (i've never done it) :)
I have!
Important to remember the namespaces go before the attributes, but otherwise handy for putting things together.
--
Graydon Saunders | graydonish at gmail.com
Þæs oferéode, ðisses swá mæg.
-- Deor ("That passed, so may this.")
Written for BaseX 9.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery