Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xpath example #32

Open
rajaram5 opened this issue Feb 2, 2018 · 5 comments
Open

xpath example #32

rajaram5 opened this issue Feb 2, 2018 · 5 comments

Comments

@rajaram5
Copy link

rajaram5 commented Feb 2, 2018

Hello,

I was trying to generate subject url with IDs from two different nodes (Child and parent node). For example, lets say that I want to generate url of this pattern <http://www.example.com/note/{notes id}/{note id}> is it possible to generate this url pattern in RML? I also tried using ancestor:: option in the RML but, it didn't work.

Example XML:

<?xml version="1.0" encoding="UTF-8"?>
<notes id="Notebook2">
<note id="M17" day="10" month="01" year="2008"> 
        <to>Tove</to>
        <from>Jani</from>
        <heading>Reminder</heading>
        <body>Don't forget me this weekend!</body>
</note>
<note id="M18" day="10" month="02" year="2008"> 
        <to>Chris</to>
        <from>Rick</from>
        <heading>Update</heading>
        <body>We now leave at six</body>
</note>
</notes>

Example RML (Not working)

@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix  rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix mail: <http://example.com/mail#>.
@base <http://example.com/base> .

<#FromToMaps>
rml:logicalSource [ 
	rml:source "/home/rajaram/work/zin-byod/rr-work/test.xml";
        rml:referenceFormulation ql:XPath;
	rml:iterator "/notes";
];
rr:subjectMap [
        rr:template "http://www.example.com/note/{@id}/{/note/@id}"; 
        rr:class mail:note;
 ].
@pheyvaer
Copy link
Collaborator

pheyvaer commented Feb 2, 2018

Hi,

The following mapping works and should achieve what you want. More specific, I changed the iterator and the template. Now you iterate over all notes instead of only the notebooks and I use the ancestor to get the id of the notebook.

<#FromToMaps>
rml:logicalSource [
        rml:source "input.xml";
        rml:referenceFormulation ql:XPath;
        rml:iterator "/notes/note";
];
rr:subjectMap [
        rr:template "http://www.example.com/note/{ancestor::notes/@id}/{@id}"; 
        rr:class mail:note;
 ].

@rajaram5
Copy link
Author

rajaram5 commented Feb 2, 2018

Hi Pieter,

Thank you for your reply, but the proposed solution is not working for me. I am using RMLMapper v0.3.1

@pheyvaer
Copy link
Collaborator

pheyvaer commented Feb 2, 2018

Indeed, apparently the ancestor operator is not supported. I'll have a closer look.

@pheyvaer
Copy link
Collaborator

pheyvaer commented Feb 2, 2018

Apparently the XML/XPath library that we are using does not supported the ancestor operator. If you by any chance know about a Java library that does we can help in replacing the current one with the new one.

@rajaram5
Copy link
Author

rajaram5 commented Feb 5, 2018

I don't work much with XML library but I can have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants