Occurrence (query directive)
Contents |
Description
Gets the occurrence with specified type and version from the active column value of input. You can leave out the version to get all occurrences of a type or both parameters to get all occurrences in the topic.
If you specify both the type and the version but no such occurrence exists, will return null. If you leave out one or both of them, will return an empty result if no matching occurrences are found.
If you don't specify the version parameter, then the version will be added as a column in the result row. If you don't specify the type either then that also will be added to the result row.
Constructor
Occurrence([TopicOperand type][,TopicOperand version])
Notes
The version is usually one of the standard language topics. You can get these using the getLang method in XTMPSI class. To use this you need to include org.wandora.topicmap package. See examples on how to do this.
Examples
Following example gets all instances of the input topic which have an occurrence with the value of a string literal "Test". Note the use of XTMPSI.getLang method to get the language topic subject identifier. This method can also be given null as a parameter to get the language independent topic.
importPackage(org.wandora.query2); importPackage(org.wandora.topicmap); new Occurrence("http://www.wandora.org/occurrence",XTMPSI.getLang("en")) .as("#occ") .from(new Instances()) .where("#occ","=","\"Test\"")