Hi Gary,

If Beverley's response doesn't quite hit the spot for you, I'd generally
go with subclassing:

PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fibo: <http://example.com/fibo/>
PREFIX dom:  <http://example.com/products/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

INSERT DATA
{
  GRAPH <http://example.com/field-mappings-1>
  {
    fibo:FullPhoneNumber rdfs:subClassOf dom:phone .
    fibo:CUPHONE         rdfs:subClassOf dom:phone .
    fibo:Telephone       rdfs:subClassOf dom:phone .
    fibo:TEL-TYPE-1      rdfs:subClassOf dom:phone .
  }
}



Then to query, either use the subClassOf.rules with inferencing { ?who
dom:phone ?number } , or:

PREFIX dom: <http://example.com/products/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?who ?number
FROM <http://example.com/field-mappings-1>
WHERE
{
  ?who ?link ?number .
  ?link rdfs:subClassOf dom:phone .
}



Regards,

  Ed



On 4/9/16, 10:28 PM, "Gary Russo" <[email protected]> wrote:

>What Combination SPARQL Query should be used to query phone numbers from
>documents where field names vary?
>
>I'd like to used triples to do the field mapping.
>
>The following triples are may be used to map the various phone number
>fields
>to dom:phone.
>
>PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>PREFIX fibo: <http://example.com/fibo/>
>PREFIX dom:  <http://example.com/products/>
>
>INSERT DATA
>{
>  GRAPH <http://example.com/field-mappings-1>
>  {
>    fibo:FullPhoneNumber rdf:type dom:phone .
>    fibo:CUPHONE         rdf:type dom:phone .
>    fibo:Telephone       rdf:type dom:phone .
>    fibo:TEL-TYPE-1      rdf:type dom:phone .
>  }
>}
>
>
>Here are the 3 XML documents that use different field names for a
>telephone
>number.
>
>/party/1001.xml
>
><fibo:Party xmlns:aptp="http://example.com/fibo";>
>    <fibo:Source>SystemA</fibo:Source>
>    <fibo:Customer>Xerox</fibo:Customer>
>    <fibo:Created>2016-02-26</fibo:Created>
>    <fibo:LastModified>2016-02-26</fibo:LastModified>
>    <fibo:Person>
>        <fibo:FullName>Grace Hopper</fibo:FullName>
>        <fibo:FullPhoneNumber>11-301-555-1212</fibo:FullPhoneNumber>
>        <fibo:city>Sunnyvale</fibo:city>
>        <fibo:state>California</fibo:state>
>    </fibo:Person>
></fibo:Party>
>
>
>/party/1002.xml
>
><fibo:Party xmlns:aptp="http://example.com/fibo";>
>    <fibo:Source>SystemB</fibo:Source>
>    <fibo:Customer>Apple</fibo:Customer>
>    <fibo:Created>2016-02-26</fibo:Created>
>    <fibo:LastModified>2016-02-26</fibo:LastModified>
>    <fibo:Person>
>        <fibo:FullName>Marissa Mayer</fibo:FullName>
>        <fibo:CUPHONE>11-301-555-4444</fibo:CUPHONE>
>        <fibo:city>Los Angeles</fibo:city>
>        <fibo:state>California</fibo:state>
>    </fibo:Person>
></fibo:Party>
>
>
>/party/1003.xml
>
><fibo:Party xmlns:aptp="http://example.com/fibo";>
>    <fibo:Source>SystemC</fibo:Source>
>    <fibo:Customer>Microsoft</fibo:Customer>
>    <fibo:Created>2016-02-26</fibo:Created>
>    <fibo:LastModified>2016-02-26</fibo:LastModified>
>    <fibo:Person>
>        <fibo:FullName>Sheryl Sandberg</fibo:FullName>
>        <fibo:Telephone type="1">301-555-1212</fibo:Telephone>
>        <fibo:city>Redmond</fibo:city>
>        <fibo:state>Washington</fibo:state>
>    </fibo:Person>
></fibo:Party>
>
>
>What query should be used to retrieve the phone numbers for all 3
>documents
>using the field mapping triples noted above?
>
>Any thoughts/advice on this is much appreciated.
>
>Regards,
>Gary Russo
>
>
>
>_______________________________________________
>General mailing list
>[email protected]
>Manage your subscription at:
>http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to