I am a newbie to OWL, and I have defined a node using OWL DL, as
<Declaration>
<Class IRI="#node"/>
</Declaration>
<Declaration>
<ObjectProperty IRI="#leftChild"/>
</Declaration>
<Declaration>
<ObjectProperty IRI="#parent"/>
</Declaration>
<Declaration>
<ObjectProperty IRI="#rightChild"/>
</Declaration>
<InverseObjectProperties>
<ObjectProperty IRI="#parent"/>
<ObjectProperty IRI="#leftChild"/>
</InverseObjectProperties>
<InverseObjectProperties>
<ObjectProperty IRI="#parent"/>
<ObjectProperty IRI="#rightChild"/>
</InverseObjectProperties>
<FunctionalObjectProperty>
<ObjectProperty IRI="#leftChild"/>
</FunctionalObjectProperty>
<FunctionalObjectProperty>
<ObjectProperty IRI="#parent"/>
</FunctionalObjectProperty>
<FunctionalObjectProperty>
<ObjectProperty IRI="#rightChild"/>
</FunctionalObjectProperty>
<ObjectPropertyDomain>
<ObjectProperty IRI="#leftChild"/>
<Class IRI="#node"/>
</ObjectPropertyDomain>
<ObjectPropertyDomain>
<ObjectProperty IRI="#parent"/>
<Class IRI="#node"/>
</ObjectPropertyDomain>
<ObjectPropertyDomain>
<ObjectProperty IRI="#rightChild"/>
<Class IRI="#node"/>
</ObjectPropertyDomain>
<ObjectPropertyRange>
<ObjectProperty IRI="#leftChild"/>
<Class IRI="#node"/>
</ObjectPropertyRange>
<ObjectPropertyRange>
<ObjectProperty IRI="#parent"/>
<Class IRI="#node"/>
</ObjectPropertyRange>
<ObjectPropertyRange>
<ObjectProperty IRI="#rightChild"/>
<Class IRI="#node"/>
</ObjectPropertyRange>
`
and I would like to define concepts as root, branch ad leaves, so as to infer and segregate nodes as root, branches and leaves,as root will have no parent, branch having a parent ad atleast one child, and leaves having only parent and no child, or orphan nodes having no parent ad no child.
If you want this hierarchy to match the subclass hierarchy in your ontology, you can use SubClassOf axioms to connect ancestors and children. Then, your roots will be the ones whose only ancestor is owl:Thing, your leaves will be the ones whose only descendant is owl:Nothing, and your branches will be all the remaining classes.
Related
When looking at this XML tree:
<ids>
<id>
<id>1</id>
<qty>0.0000</qty>
</id>
<id>
<id>2</id>
<qty>0.0000</qty>
</id>
<id>
<id>3</id>
<qty>0.0000</qty>
</id>
<id>
<id>4</id>
<qty>10.0000</qty>
</id>
<id>
<id>5</id>
<qty>0.0000</qty>
</id>
</ids>
How would one go about choosing the qty with a sibling id of 4?
So far I've tried:
<xsl:value-of select="ids/id[id = '4']/qty"/>
<xsl:value-of select="ids/id/qty[../id = '4']"/>
However, the only result that is ever returned is qty = 0.0000.
Try this XPath-1.0 expression:
/ids/id[id='4']/qty
I am looking for an XPath expression that selects the hims that have parent, gramps's with name's that have the same root name with the hims having a Jr suffix and there is a store name that looks like it is named after a gramps. In the example below that would only be Bill.
<root>
<gramps name="Bill">
<him name="Bill Jr">
<kid name="Bill III"></kid>
</him>
</gramps>
<gramps name="Tom">
<him name="Al">
<kid name="Al Jr"></kid>
</him>
</gramps>
<gramps name="Bob">
<him name="Bob Jr">
<kid name="Sam"></kid>
</him>
</gramps>
<store name="Bill's" />
<store name="Tom's" />
<store name="Pete's" />
</root>
I think this will select what you need...
/*/gramps[../store/#name=concat(#name,"'s")]/him[#name=concat(../#name,' Jr')]
This will select Bill Jr because you said you wanted to select the him.
If you want to select the gramps (Bill), just put him in a predicate...
/*/gramps[../store/#name=concat(#name,"'s")][him[#name=concat(../#name,' Jr')]]
<?xml version="1.0" encoding="UTF-8"?>
<Patients>
<patientRole>
<id extension="996-756-495" root="2.16.840.1.113883.19.5"/>
<id extension="775-756-495" root="2.16.840.1.113883.14.6"/>
<patient>
<name>
<given>Henry</given>
<family>Levin</family>
</name>
<administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
<birthTime value="19320924"/>
</patient>
<providerOrganization>
<id root="2.16.840.1.113883.19.5"/>
<name>Good Health Clinic</name>
</providerOrganization>
<admissionTime value="2012030111:32"/>
</patientRole>
<patientRole>
<id extension="65" root="2.16.840.1.113883.3.933"/>
<patient>
<name>
<given>Paul</given>
<family>Pappel</family>
</name>
<administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
<birthTime value="19551217"/>
</patient>
<providerOrganization>
<id extension="84756-11241-283-OPTD-3322" root="1.2.3.4.5.6.1.8.9.0"/>
<name> Dr.med. Hans Topp-Glucklich</name>
</providerOrganization>
<admissionTime value="201201152200"/>
</patientRole>
<patientRole>
<id extension="800001" root="2.16.840.1.113883.19.5"/>
<patient>
<name>
<given>JEANNE</given>
<family>PETIT</family>
</name>
<administrativeGenderCode code="F" codeSystem="2.16.840.1.113883.5.1"/>
<birthTime value="19480105"/>
</patient>
<providerOrganization>
<id root="2.16.840.1.113883.19.5"/>
<name>Good Health Clinic</name>
</providerOrganization>
<admissionTime value="20120101T22:00"/>
</patientRole>
</Patients>
I am having difficulty writing XPath expressions for the following two items:
Given and family name of the patient born on 17 Dec 1955
Number of patients admitted to "Good Health Clinic" in January 2012
This will get you the name element of the patients born on the particular date:
patientRole/patient[birthTime/#value="19551217"]/name
This will get you the count of patientRole elements with the organisation name and admission date specified:
count(patientRole[providerOrganization/name="Good Health Clinic"][starts-with(admissionTime/#value,"201201")])
Given the following sample:
<?xml version="1.0" encoding="UTF-8"?>
<Patients>
<patientRole>
<id extension="996-756-495" root="2.16.840.1.113883.19.5"/>
<id extension="775-756-495" root="2.16.840.1.113883.14.6"/>
<patient>
<name>
<given>Henry</given>
<family>Levin</family>
</name>
<administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
<birthTime value="19320924"/>
</patient>
<providerOrganization>
<id root="2.16.840.1.113883.19.5"/>
<name>Good Health Clinic</name>
</providerOrganization>
<admissionTime value="2012030111:32"/>
</patientRole>
<patientRole>
<id extension="65" root="2.16.840.1.113883.3.933"/>
<patient>
<name>
<given>Paul</given>
<family>Pappel</family>
</name>
<administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
<birthTime value="19551217"/>
</patient>
<providerOrganization>
<id extension="84756-11241-283-OPTD-3322" root="1.2.3.4.5.6.1.8.9.0"/>
<name> Dr.med. Hans Topp-Glucklich</name>
</providerOrganization>
<admissionTime value="201201152200"/>
</patientRole>
<patientRole>
<id extension="800001" root="2.16.840.1.113883.19.5"/>
<patient>
<name>
<given>JEANNE</given>
<family>PETIT</family>
</name>
<administrativeGenderCode code="F" codeSystem="2.16.840.1.113883.5.1"/>
<birthTime value="19480105"/>
</patient>
<providerOrganization>
<id root="2.16.840.1.113883.19.5"/>
<name>Good Health Clinic</name>
</providerOrganization>
<admissionTime value="20120101T22:00"/>
</patientRole>
</Patients>
How would I write a X-Path expression for the following:
Family names for the male patients (gender code="M")
Any help is greatly appreciated I am new to XML/Xpath and i have tried multiple ways and its not generating what i need.
This should work:
/Patients/patientRole/patient[administrativeGenderCode/#code='M']/name/family
Do you think I can adjust the xml output from GraphML?
In the GraphML wiki the tags seem to be fixed:
<graphml>
<graph>
<node>
<data></data>
</node>
<edge>
<data></data>
</edge>
</graph>
</graphml>
I saw that you can change the tag attributes.
Do you think I could customize the tags itself to something like <car></car>?
If you need to add new elements, you would have to modify the DTD. In that case, your data would no longer be GraphML, but your own standard due to the DTD customization. Here is the GraphML DTD:
<!-- ====================================================================== -->
<!-- file: graphml.dtd ======================================================
This is the Document Type Definition for the release candidate of
GraphML version 1.0 and represents a (necessarily) looser specification
than the corresponding XML Schema. It's use is discouraged, though it
may be necessary for some systems.
Usage:
SYSTEM "http://graphml.graphdrawing.org/dtds/1.0rc/graphml.dtd"
xmlns="http://graphml.graphdrawing.org/xmlns/1.0rc"
====================================================================== -->
<!-- ===============================================================-->
<!--Parameter entity for data content -->
<!--================================================================-->
<!ENTITY % GRAPHML.data.content "(#PCDATA)">
<!-- ===============================================================-->
<!--Parameter entities for attribute list extensions -->
<!--================================================================-->
<!ENTITY % GRAPHML.graphml.attrib "">
<!ENTITY % GRAPHML.locator.attrib "">
<!ENTITY % GRAPHML.graph.attrib "">
<!ENTITY % GRAPHML.node.attrib "">
<!ENTITY % GRAPHML.port.attrib "">
<!ENTITY % GRAPHML.edge.attrib "">
<!ENTITY % GRAPHML.hyperedge.attrib "">
<!ENTITY % GRAPHML.endpoint.attrib "">
<!ENTITY % GRAPHML.key.attrib "">
<!ENTITY % GRAPHML.data.attrib "">
<!ENTITY % GRAPHML.default.attrib "">
<!--============================================================-->
<!--Attributes used by each GRAPHML element-->
<!--============================================================-->
<!ENTITY % GRAPHML.common.attrib
""
>
<!--================================================================-->
<!--the graphml elements-->
<!--================================================================-->
<!ELEMENT data %GRAPHML.data.content;>
<!ATTLIST data
key IDREF #REQUIRED
id ID #IMPLIED
%GRAPHML.data.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT default %GRAPHML.data.content;>
<!ATTLIST default
%GRAPHML.default.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT key (desc?,default?)>
<!ATTLIST key
id ID #REQUIRED
for (graph|node|edge|hyperedge|port|endpoint|all) "all"
%GRAPHML.key.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT graphml (desc?,key*,(data|graph)*)>
<!ATTLIST graphml
%GRAPHML.graphml.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT graph (desc?,(((data|node|edge|hyperedge)*)|locator))>
<!ATTLIST graph
id ID #IMPLIED
edgedefault (directed|undirected) #REQUIRED
%GRAPHML.graph.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT node (desc?,((((data|port)*,graph?))|locator))>
<!ATTLIST node
id ID #REQUIRED
%GRAPHML.node.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT port (desc?,(data|port)*)>
<!ATTLIST port
name NMTOKEN #REQUIRED
%GRAPHML.port.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT edge (desc?,data*,graph?)>
<!ATTLIST edge
id ID #IMPLIED
source IDREF #REQUIRED
sourceport NMTOKEN #IMPLIED
target IDREF #REQUIRED
targetport NMTOKEN #IMPLIED
directed (true|false) #IMPLIED
%GRAPHML.edge.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT hyperedge (desc?,(data|endpoint)*,graph?)>
<!ATTLIST hyperedge
id ID #IMPLIED
%GRAPHML.hyperedge.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT endpoint (desc?)>
<!ATTLIST endpoint
id ID #IMPLIED
node IDREF #REQUIRED
port NMTOKEN #IMPLIED
type (in|out|undir) "undir"
%GRAPHML.endpoint.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT locator EMPTY>
<!ATTLIST locator
xmlns:xlink CDATA #FIXED "http://www.w3.org/TR/2000/PR-xlink-20001220/"
xlink:href CDATA #REQUIRED
xlink:type (simple) #FIXED "simple"
%GRAPHML.locator.attrib;
%GRAPHML.common.attrib;
>
<!ELEMENT desc (#PCDATA)>
<!ATTLIST desc %GRAPHML.common.attrib;>
References
Comparison between XML to SVG Transformation Mechanisms