question
Wednesday, 29 July 2015 · 12 messages · last reply 30 Jul 2015
RS
Rob Stapper29 Jul 2015 16:54 #
Hello,
I must be overlooking something, so excuses in advance, but: How can I retrieve the datatype of a variable?
TIA,
Rob Stapper
---
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus
FG
Hi,
That would base the type annotation on the lexical value. For instance, the string '0' would be labelled as "integer" (given you test for xs:integer before xs:string):
let $var := '0'
return
if ( $var castable as xs:integer )
then 'integer'
else if ( $var castable as xs:string )
then 'string'
else
'unknown type'
(: -> 'integer' :)The operator "instance of" would solve that problem. But then, for that purpose, there is the "typeswitch" instruction:
typeswitch ( '0' )
case xs:integer return
'integer'
case xs:string return
'string'
default return
'unknown type'
(: -> 'string' :)
Regards,
--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/
Quoted text · Eliot Kimber · 61 lines
On 29 July 2015 at 17:34, Eliot Kimber <ekimber at contrext.com> wrote: > I believe you need to use the "castable as" or "instance of" operators to > determine the type, e.g.: > > let $typeName := > if ($somevar castable as xs:integer) > then 'integer' > else if ($somevar castable as xs:string) > then 'string' > else 'unknown type' > > Or something close to that. There is also "instance of", which might be > > I also found this paper, which might be interesting: > > http://www.balisage.net/Proceedings/vol8/html/Holstege01/BalisageVol8-Holst > ege01.html > > Cheers, > > E. > ---- > Eliot Kimber, Owner > Contrext, LLC > http://contrext.com > > > > > On 7/29/15, 9:54 AM, "Rob Stapper" > <basex-talk-bounces at mailman.uni-konstanz.de on behalf of > r.stapper at lijbrandt.nl> wrote: > >>Hello, >> >>I must be overlooking something, so excuses in advance, but: How can I >>retrieve the datatype of a variable? >> >>TIA, >>Rob Stapper >> >> >> >>________________________________________ >> >> >> >> >> <https://www.avast.com/antivirus> >> >> >> >> Dit e-mailbericht is gecontroleerd op virussen met Avast >>antivirussoftware. >> >>www.avast.com <https://www.avast.com/antivirus> >> >> >> > >
EK
I believe you need to use the "castable as" or "instance of" operators to determine the type, e.g.:
let $typeName :=
if ($somevar castable as xs:integer)
then 'integer'
else if ($somevar castable as xs:string)
then 'string'
else 'unknown type'Or something close to that. There is also "instance of", which might be
I also found this paper, which might be interesting:
http://www.balisage.net/Proceedings/vol8/html/Holstege01/BalisageVol8-Holst ege01.html
Cheers,
E.
----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com
On 7/29/15, 9:54 AM, "Rob Stapper"
<basex-talk-bounces at mailman.uni-konstanz.de on behalf of
Quoted text · Rob Stapper · 27 lines
r.stapper at lijbrandt.nl> wrote: >Hello, > >I must be overlooking something, so excuses in advance, but: How can I >retrieve the datatype of a variable? > >TIA, >Rob Stapper > > > >________________________________________ > > > > > <https://www.avast.com/antivirus> > > > > Dit e-mailbericht is gecontroleerd op virussen met Avast >antivirussoftware. > >www.avast.com <https://www.avast.com/antivirus> > > >
EK
I am happy to be corrected.
Cheers,
E.
----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com
Quoted text · Florent Georges · 104 lines
On 7/29/15, 10:42 AM, "Florent Georges" <fgeorges at gmail.com on behalf of lists at fgeorges.org> wrote: >Hi, > >That would base the type annotation on the lexical value. For >instance, the string '0' would be labelled as "integer" (given you >test for xs:integer before xs:string): > >let $var := '0' >return > if ( $var castable as xs:integer ) > then 'integer' > else if ( $var castable as xs:string ) > then 'string' > else > 'unknown type' >(: -> 'integer' :) > >The operator "instance of" would solve that problem. But then, for >that purpose, there is the "typeswitch" instruction: > >typeswitch ( '0' ) > case xs:integer return > 'integer' > case xs:string return > 'string' > default return > 'unknown type' >(: -> 'string' :) > >Regards, > >-- >Florent Georges >http://fgeorges.org/ >http://h2oconsulting.be/ > > >On 29 July 2015 at 17:34, Eliot Kimber <ekimber at contrext.com> wrote: >> I believe you need to use the "castable as" or "instance of" operators >>to >> determine the type, e.g.: >> >> let $typeName := >> if ($somevar castable as xs:integer) >> then 'integer' >> else if ($somevar castable as xs:string) >> then 'string' >> else 'unknown type' >> >> Or something close to that. There is also "instance of", which might be >> >> I also found this paper, which might be interesting: >> >> >>http://www.balisage.net/Proceedings/vol8/html/Holstege01/BalisageVol8-Hol >>st >> ege01.html >> >> Cheers, >> >> E. >> ---- >> Eliot Kimber, Owner >> Contrext, LLC >> http://contrext.com >> >> >> >> >> On 7/29/15, 9:54 AM, "Rob Stapper" >> <basex-talk-bounces at mailman.uni-konstanz.de on behalf of >> r.stapper at lijbrandt.nl> wrote: >> >>>Hello, >>> >>>I must be overlooking something, so excuses in advance, but: How can I >>>retrieve the datatype of a variable? >>> >>>TIA, >>>Rob Stapper >>> >>> >>> >>>________________________________________ >>> >>> >>> >>> >>> <https://www.avast.com/antivirus> >>> >>> >>> >>> Dit e-mailbericht is gecontroleerd op >>>virussen met Avast >>>antivirussoftware. >>> >>>www.avast.com <https://www.avast.com/antivirus> >>> >>> >>> >> >> >
RS
Rob Stapper30 Jul 2015 09:41 #
Eliot, Florent,
Thank you both for your reaction.
I've been thinking about the typeswitch-command too but it feels weird: I have this variable, inside XQuery its type is known but for retrieving it I have to go through all types and ask XQuery if it is this one. I hoped for a more direct solution.
I've been thinking about the inspect-function too but that one is more mend for documentation-purposes and I guess performance is an issue there.
Thanx again,
Rob
-----Oorspronkelijk bericht-----
Quoted text · Eliot Kimber · 119 lines
Van: Eliot Kimber [mailto:ekimber at contrext.com] Verzonden: woensdag 29 juli 2015 19:56 Aan: Florent Georges CC: Rob Stapper; BaseX Onderwerp: Re: [basex-talk] question I am happy to be corrected. Cheers, E. ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com On 7/29/15, 10:42 AM, "Florent Georges" <fgeorges at gmail.com on behalf of lists at fgeorges.org> wrote: >Hi, > >That would base the type annotation on the lexical value. For >instance, the string '0' would be labelled as "integer" (given you test >for xs:integer before xs:string): > >let $var := '0' >return > if ( $var castable as xs:integer ) > then 'integer' > else if ( $var castable as xs:string ) > then 'string' > else > 'unknown type' >(: -> 'integer' :) > >The operator "instance of" would solve that problem. But then, for >that purpose, there is the "typeswitch" instruction: > >typeswitch ( '0' ) > case xs:integer return > 'integer' > case xs:string return > 'string' > default return > 'unknown type' >(: -> 'string' :) > >Regards, > >-- >Florent Georges >http://fgeorges.org/ >http://h2oconsulting.be/ > > >On 29 July 2015 at 17:34, Eliot Kimber <ekimber at contrext.com> wrote: >> I believe you need to use the "castable as" or "instance of" >>operators to determine the type, e.g.: >> >> let $typeName := >> if ($somevar castable as xs:integer) >> then 'integer' >> else if ($somevar castable as xs:string) >> then 'string' >> else 'unknown type' >> >> Or something close to that. There is also "instance of", which might >> be >> >> I also found this paper, which might be interesting: >> >> >>http://www.balisage.net/Proceedings/vol8/html/Holstege01/BalisageVol8- >>Hol >>st >> ege01.html >> >> Cheers, >> >> E. >> ---- >> Eliot Kimber, Owner >> Contrext, LLC >> http://contrext.com >> >> >> >> >> On 7/29/15, 9:54 AM, "Rob Stapper" >> <basex-talk-bounces at mailman.uni-konstanz.de on behalf of >> r.stapper at lijbrandt.nl> wrote: >> >>>Hello, >>> >>>I must be overlooking something, so excuses in advance, but: How can >>>I retrieve the datatype of a variable? >>> >>>TIA, >>>Rob Stapper >>> >>> >>> >>>________________________________________ >>> >>> >>> >>> >>> <https://www.avast.com/antivirus> >>> >>> >>> >>> Dit e-mailbericht is gecontroleerd op >>>virussen met Avast antivirussoftware. >>> >>>www.avast.com <https://www.avast.com/antivirus> >>> >>> >>> >> >> > --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus
CG
Christian Grün30 Jul 2015 09:55 #
Hi Rob,
In that regard, XQuery is pretty similar to many other programming languages. Think e.g. of the following Java code:
public JLabel label = new JLabel();What do you think is the "data type" of the variable named "label", and how would you like to deal with it in Java?
Cheers,
Christian
Quoted text · Rob Stapper · 150 lines
On Thu, Jul 30, 2015 at 9:41 AM, Rob Stapper <r.stapper at lijbrandt.nl> wrote: > Eliot, Florent, > > Thank you both for your reaction. > > I've been thinking about the typeswitch-command too but it feels weird: I > have this variable, inside XQuery its type is known but for retrieving it I > have to go through all types and ask XQuery if it is this one. > I hoped for a more direct solution. > > I've been thinking about the inspect-function too but that one is more mend > for documentation-purposes and I guess performance is an issue there. > > Thanx again, > > Rob > > > -----Oorspronkelijk bericht----- > Van: Eliot Kimber [mailto:ekimber at contrext.com] > Verzonden: woensdag 29 juli 2015 19:56 > Aan: Florent Georges > CC: Rob Stapper; BaseX > Onderwerp: Re: [basex-talk] question > > I am happy to be corrected. > > Cheers, > > E. > ---- > Eliot Kimber, Owner > Contrext, LLC > http://contrext.com > > > > > On 7/29/15, 10:42 AM, "Florent Georges" <fgeorges at gmail.com on behalf of > lists at fgeorges.org> wrote: > >>Hi, >> >>That would base the type annotation on the lexical value. For >>instance, the string '0' would be labelled as "integer" (given you test >>for xs:integer before xs:string): >> >>let $var := '0' >>return >> if ( $var castable as xs:integer ) >> then 'integer' >> else if ( $var castable as xs:string ) >> then 'string' >> else >> 'unknown type' >>(: -> 'integer' :) >> >>The operator "instance of" would solve that problem. But then, for >>that purpose, there is the "typeswitch" instruction: >> >>typeswitch ( '0' ) >> case xs:integer return >> 'integer' >> case xs:string return >> 'string' >> default return >> 'unknown type' >>(: -> 'string' :) >> >>Regards, >> >>-- >>Florent Georges >>http://fgeorges.org/ >>http://h2oconsulting.be/ >> >> >>On 29 July 2015 at 17:34, Eliot Kimber <ekimber at contrext.com> wrote: >>> I believe you need to use the "castable as" or "instance of" >>>operators to determine the type, e.g.: >>> >>> let $typeName := >>> if ($somevar castable as xs:integer) >>> then 'integer' >>> else if ($somevar castable as xs:string) >>> then 'string' >>> else 'unknown type' >>> >>> Or something close to that. There is also "instance of", which might >>> be >>> >>> I also found this paper, which might be interesting: >>> >>> >>>http://www.balisage.net/Proceedings/vol8/html/Holstege01/BalisageVol8- >>>Hol >>>st >>> ege01.html >>> >>> Cheers, >>> >>> E. >>> ---- >>> Eliot Kimber, Owner >>> Contrext, LLC >>> http://contrext.com >>> >>> >>> >>> >>> On 7/29/15, 9:54 AM, "Rob Stapper" >>> <basex-talk-bounces at mailman.uni-konstanz.de on behalf of >>> r.stapper at lijbrandt.nl> wrote: >>> >>>>Hello, >>>> >>>>I must be overlooking something, so excuses in advance, but: How can >>>>I retrieve the datatype of a variable? >>>> >>>>TIA, >>>>Rob Stapper >>>> >>>> >>>> >>>>________________________________________ >>>> >>>> >>>> >>>> >>>> <https://www.avast.com/antivirus> >>>> >>>> >>>> >>>> Dit e-mailbericht is gecontroleerd op >>>>virussen met Avast antivirussoftware. >>>> >>>>www.avast.com <https://www.avast.com/antivirus> >>>> >>>> >>>> >>> >>> >> > > > > --- > Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. > https://www.avast.com/antivirus >
RS
Rob Stapper30 Jul 2015 11:04 #
Hi Christian,
I would say that datatype of variable "label" is JLabel.
If I was programming in Java I guess I want Java to return the string: "JLabel" probably combined with the URI of the source were JLabel is defined.
Cheers,
Rob.
PS. I'm no Java-programmer ( yet :-)
-----Oorspronkelijk bericht-----
Quoted text · Christian Grün · 165 lines
Van: Christian Grün [mailto:christian.gruen at gmail.com] Verzonden: donderdag 30 juli 2015 9:55 Aan: Rob Stapper CC: Eliot Kimber; Florent Georges; BaseX Onderwerp: Re: [basex-talk] question Hi Rob, In that regard, XQuery is pretty similar to many other programming languages. Think e.g. of the following Java code: public JLabel label = new JLabel(); What do you think is the "data type" of the variable named "label", and how would you like to deal with it in Java? Cheers, Christian On Thu, Jul 30, 2015 at 9:41 AM, Rob Stapper <r.stapper at lijbrandt.nl> wrote: > Eliot, Florent, > > Thank you both for your reaction. > > I've been thinking about the typeswitch-command too but it feels > weird: I have this variable, inside XQuery its type is known but for > retrieving it I have to go through all types and ask XQuery if it is this one. > I hoped for a more direct solution. > > I've been thinking about the inspect-function too but that one is more > mend for documentation-purposes and I guess performance is an issue there. > > Thanx again, > > Rob > > > -----Oorspronkelijk bericht----- > Van: Eliot Kimber [mailto:ekimber at contrext.com] > Verzonden: woensdag 29 juli 2015 19:56 > Aan: Florent Georges > CC: Rob Stapper; BaseX > Onderwerp: Re: [basex-talk] question > > I am happy to be corrected. > > Cheers, > > E. > ---- > Eliot Kimber, Owner > Contrext, LLC > http://contrext.com > > > > > On 7/29/15, 10:42 AM, "Florent Georges" <fgeorges at gmail.com on behalf > of lists at fgeorges.org> wrote: > >>Hi, >> >>That would base the type annotation on the lexical value. For >>instance, the string '0' would be labelled as "integer" (given you >>test for xs:integer before xs:string): >> >>let $var := '0' >>return >> if ( $var castable as xs:integer ) >> then 'integer' >> else if ( $var castable as xs:string ) >> then 'string' >> else >> 'unknown type' >>(: -> 'integer' :) >> >>The operator "instance of" would solve that problem. But then, for >>that purpose, there is the "typeswitch" instruction: >> >>typeswitch ( '0' ) >> case xs:integer return >> 'integer' >> case xs:string return >> 'string' >> default return >> 'unknown type' >>(: -> 'string' :) >> >>Regards, >> >>-- >>Florent Georges >>http://fgeorges.org/ >>http://h2oconsulting.be/ >> >> >>On 29 July 2015 at 17:34, Eliot Kimber <ekimber at contrext.com> wrote: >>> I believe you need to use the "castable as" or "instance of" >>>operators to determine the type, e.g.: >>> >>> let $typeName := >>> if ($somevar castable as xs:integer) >>> then 'integer' >>> else if ($somevar castable as xs:string) >>> then 'string' >>> else 'unknown type' >>> >>> Or something close to that. There is also "instance of", which might >>> be >>> >>> I also found this paper, which might be interesting: >>> >>> >>>http://www.balisage.net/Proceedings/vol8/html/Holstege01/BalisageVol8 >>>- >>>Hol >>>st >>> ege01.html >>> >>> Cheers, >>> >>> E. >>> ---- >>> Eliot Kimber, Owner >>> Contrext, LLC >>> http://contrext.com >>> >>> >>> >>> >>> On 7/29/15, 9:54 AM, "Rob Stapper" >>> <basex-talk-bounces at mailman.uni-konstanz.de on behalf of >>> r.stapper at lijbrandt.nl> wrote: >>> >>>>Hello, >>>> >>>>I must be overlooking something, so excuses in advance, but: How can >>>>I retrieve the datatype of a variable? >>>> >>>>TIA, >>>>Rob Stapper >>>> >>>> >>>> >>>>________________________________________ >>>> >>>> >>>> >>>> >>>> <https://www.avast.com/antivirus> >>>> >>>> >>>> >>>> Dit e-mailbericht is gecontroleerd op >>>>virussen met Avast antivirussoftware. >>>> >>>>www.avast.com <https://www.avast.com/antivirus> >>>> >>>> >>>> >>> >>> >> > > > > --- > Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. > https://www.avast.com/antivirus > --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus
CG
Christian Grün30 Jul 2015 11:14 #
Quoted text · Rob Stapper · 1 line
> If I was programming in Java I guess I want Java to return the string: "JLabel" probably combined with the URI of the source were JLabel is defined.
In that case, you would have to work with the reflection features of Java. In BaseX, the equivalent facility is (as you already guessed) the Inspection Module.
However, I wouldn't recommend you to follow this path, as you would soon end up doing all kinds of things with string comparisons. What are you actually trying to attain with the string representation of types?
RS
Eliot,
Thanx for the link. I studying it right now :-)
Rob
-----Oorspronkelijk bericht-----
Quoted text · Eliot Kimber · 55 lines
Van: Eliot Kimber [mailto:ekimber at contrext.com] Verzonden: woensdag 29 juli 2015 17:35 Aan: Rob Stapper; BaseX Onderwerp: Re: [basex-talk] question I believe you need to use the "castable as" or "instance of" operators to determine the type, e.g.: let $typeName := if ($somevar castable as xs:integer) then 'integer' else if ($somevar castable as xs:string) then 'string' else 'unknown type' Or something close to that. There is also "instance of", which might be I also found this paper, which might be interesting: http://www.balisage.net/Proceedings/vol8/html/Holstege01/BalisageVol8-Holst ege01.html Cheers, E. ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com On 7/29/15, 9:54 AM, "Rob Stapper" <basex-talk-bounces at mailman.uni-konstanz.de on behalf of r.stapper at lijbrandt.nl> wrote: >Hello, > >I must be overlooking something, so excuses in advance, but: How can I >retrieve the datatype of a variable? > >TIA, >Rob Stapper > > > >________________________________________ > > > > > <https://www.avast.com/antivirus> > > > > Dit e-mailbericht is gecontroleerd op virussen met Avast >antivirussoftware. > >www.avast.com <https://www.avast.com/antivirus> > > > --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus
RS
:-)
Well, I'm using, what you could call negative logic on domain-subsets. For example:
- say we have a domain: "pears" containing pears and a domain: "apples" containing apples.
- say we define a subset on the "apples"-domain as: "all apples from domain: "apples", except apple: <some_apple_id>, and apple: <some_other_apple_id>"
- say we have a pear form the "pears"-domain with id: <some_pear_id>.
- if I want to test if the apple-subset contains this pear I must check the domain, i.o.w. type, of the pear against the domain, i.o.w. type, of the apple-subset. If I don't the answer to this question would be: "true", which is wrong. In that case I'm not referring to the apple-domain but to literal everything. And yes, everything also contains this pear.
I could make the domain-name a part of the identification but that is only possible for my self defined datatypes and not for XQuery's native datatypes.
I bit of a complex story but I hope it makes sense to you.
Rob
-----Oorspronkelijk bericht-----
Quoted text · Christian Grün · 11 lines
Van: Christian Grün [mailto:christian.gruen at gmail.com] Verzonden: donderdag 30 juli 2015 11:14 Aan: Rob Stapper CC: Eliot Kimber; Florent Georges; BaseX Onderwerp: Re: [basex-talk] question > If I was programming in Java I guess I want Java to return the string: "JLabel" probably combined with the URI of the source were JLabel is defined. In that case, you would have to work with the reflection features of Java. In BaseX, the equivalent facility is (as you already guessed) the Inspection Module. However, I wouldn't recommend you to follow this path, as you would soon end up doing all kinds of things with string comparisons. What are you actually trying to attain with the string representation of types? --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus
CG
Christian Grün30 Jul 2015 12:51 #
Quoted text · Rob Stapper · 1 line
> I bit of a complex story but I hope it makes sense to you.
Hm. I still don't see why typeswitch wouldn't help as well, but your use case may indeed be too complex to break it down to a few sentences.. ;)
But if you think it cannot be solved with static type checks (i.e., with "typeswitch" and "instance of"), you should probably do what has been motivated by Florent, and write a function that gives you the string representation of types )(see e.g. Priscilla Walmsley's solution for atomic types [1]). Do you also need a string
representation of function items?
Christian
[1] http://www.xqueryfunctions.com/xq/functx_atomic-type.html
Quoted text · Rob Stapper · 29 lines
> - say we have a domain: "pears" containing pears and a domain: "apples" containing apples. > - say we define a subset on the "apples"-domain as: "all apples from domain: "apples", except apple: <some_apple_id>, and apple: <some_other_apple_id>" > - say we have a pear form the "pears"-domain with id: <some_pear_id>. > - if I want to test if the apple-subset contains this pear I must check the domain, i.o.w. type, of the pear against the domain, i.o.w. type, of the apple-subset. > If I don't the answer to this question would be: "true", which is wrong. In that case I'm not referring to the apple-domain but to literal everything. And yes, everything also contains this pear. > > I could make the domain-name a part of the identification but that is only possible for my self defined datatypes and not for XQuery's native datatypes. > > > Rob > > -----Oorspronkelijk bericht----- > Van: Christian Grün [mailto:christian.gruen at gmail.com] > Verzonden: donderdag 30 juli 2015 11:14 > Aan: Rob Stapper > CC: Eliot Kimber; Florent Georges; BaseX > Onderwerp: Re: [basex-talk] question > >> If I was programming in Java I guess I want Java to return the string: "JLabel" probably combined with the URI of the source were JLabel is defined. > > In that case, you would have to work with the reflection features of Java. In BaseX, the equivalent facility is (as you already guessed) the Inspection Module. > > However, I wouldn't recommend you to follow this path, as you would soon end up doing all kinds of things with string comparisons. What are you actually trying to attain with the string representation of types? > > > --- > Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. > https://www.avast.com/antivirus >
RS
Rob Stapper30 Jul 2015 14:47 #
Typeswitch would indeed help but as I already mentioned it feels a bit, well ... off. It would not be my first choice. Looking at Priscilla's solution I and probably also you can understand why.
Yes I also do need string representation for functiontypes: probably a typeswitch will do for map and arrays. I've built me own userdatatypedefinition-module based on closure-functions which already has a function for returning string representations, so that won't be a problem.
Since I've a few other modules which would be better off as integrated part of the runtime ( a tracer for instance) I'm thinking about building it into the Basex core in Java. This would ask for mega effort especially since I'm unknown to Java and its develement-environment. Any advise here?
Well, lots to do.
Rob
-----Oorspronkelijk bericht-----
Quoted text · Christian Grün · 42 lines
Van: Christian Grün [mailto:christian.gruen at gmail.com] Verzonden: donderdag 30 juli 2015 12:52 Aan: Rob Stapper CC: Eliot Kimber; Florent Georges; BaseX Onderwerp: Re: [basex-talk] question > I bit of a complex story but I hope it makes sense to you. Hm. I still don't see why typeswitch wouldn't help as well, but your use case may indeed be too complex to break it down to a few sentences.. ;) But if you think it cannot be solved with static type checks (i.e., with "typeswitch" and "instance of"), you should probably do what has been motivated by Florent, and write a function that gives you the string representation of types )(see e.g. Priscilla Walmsley's solution for atomic types [1]). Do you also need a string representation of function items? Christian [1] http://www.xqueryfunctions.com/xq/functx_atomic-type.html > - say we have a domain: "pears" containing pears and a domain: "apples" containing apples. > - say we define a subset on the "apples"-domain as: "all apples from domain: "apples", except apple: <some_apple_id>, and apple: <some_other_apple_id>" > - say we have a pear form the "pears"-domain with id: <some_pear_id>. > - if I want to test if the apple-subset contains this pear I must check the domain, i.o.w. type, of the pear against the domain, i.o.w. type, of the apple-subset. > If I don't the answer to this question would be: "true", which is wrong. In that case I'm not referring to the apple-domain but to literal everything. And yes, everything also contains this pear. > > I could make the domain-name a part of the identification but that is only possible for my self defined datatypes and not for XQuery's native datatypes. > > > Rob > > -----Oorspronkelijk bericht----- > Van: Christian Grün [mailto:christian.gruen at gmail.com] > Verzonden: donderdag 30 juli 2015 11:14 > Aan: Rob Stapper > CC: Eliot Kimber; Florent Georges; BaseX > Onderwerp: Re: [basex-talk] question > >> If I was programming in Java I guess I want Java to return the string: "JLabel" probably combined with the URI of the source were JLabel is defined. > > In that case, you would have to work with the reflection features of Java. In BaseX, the equivalent facility is (as you already guessed) the Inspection Module. > > However, I wouldn't recommend you to follow this path, as you would soon end up doing all kinds of things with string comparisons. What are you actually trying to attain with the string representation of types? > > > --- > Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. > https://www.avast.com/antivirus > --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus
Written for BaseX 8.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery