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@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