I open the XML file (sample attached) using the Semantic XML Documents
and then I can see all the classes and instances,
the process flow will be selecting a file (later root folder and then
iterating it) and then converting it to spreadsheet and hten exporting
it to text/xls.
while converting it to spreasheet I am finding hard time to write the
sparql query for selecting the tags.
Example is a sample from the google:
SELECT *
WHERE {
?var dcterms:abstract ?abstract .
?var dcterms:author ?author.
?var dc:title ?title .
}
I am not sure how this works. I mean how do I know what are the tag
types (dcterms, dc, prism)
Pls guide me.
Let's start with Semantic XML. See Help > Import and Export >
Creating, Importing, Querying, Saving XML documents with Semantic XML
Semantic XML applies a default RDF form to XML files. Each XML
element/tag name is mapped into an OWL class, attributes are mapped to
OWL datatype properties, parent-child relationships between the XML
elements are expressed with composite:child, composite:index is used
to order sibling tags, etc. (see the Help file).
Can I get you to clarify what you mean by "Example is a sample from
the google: " and the purpose of the SPARQL query. I.e. is the query
of the form you would like to transform the XML into?
As I said this is a nice example, on a common topic, and I'd like to
step through this as a mini-tutorial in a series of posts. Next will
be on extracting data from the XML file.
-- Scott
On Feb 21, 11:22 pm, sue <vk.ontolog...@gmail.com> wrote:
> Publisher.xml
> 39KViewDownload
I was just googling on how to write sparql query for selecting data
and I came across a post on this group and it had some query
so I was wondering how will I know what are the prefixes (dc, dcterms,
prism) which I have to use for selecting the variables to write the
query.
I would go through the Help section as advised by you and will wait
for your next post (mini tutorial) .
Thanks once again :)
On Feb 22, 10:22 am, Scott Henninger <shennin...@topquadrant.com>
wrote:
> Sue; There are quite a few issues here. It's a common example and
> I'd like to turn this into an example for our Web page (http://www.topquadrant.com/products/SPARQLMotion.html) Would that be OK with
What you are calling tag types are namespace prefixes. They are used for convenience so one does not have to use an entire URI.
dc:title = http://purl.org/dc/elements/1.1/title
You can define prefixes for your namespaces or not. This is up to you.
--
You received this message because you are subscribed to the Google Groups
"TopBraid Composer Users" group.
To post to this group, send email to topbraid-co...@googlegroups.com.
To unsubscribe from this group, send email to
topbraid-composer...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/topbraid-composer-users?hl=en.
--
<One question here though, the variables ?doc, ?absText ?txtNode are
user
defined or its predefine (XML tags) ?>
They are variables. For example, the triple pattern:
?doc a :Abstract .
...means find all triples matching "anything - rdf:type ('a' is a
shortcut) - :Abstract"
?doc a :Abstract .
?doc composite:child ?absText .
...means find all graphs with "anything" as the subject and both:
- a rdf:type property whose value is :Abstract
- a composite:child property with any value
Much more to SPARQL that's probably beyond the scope of this forum.
To select all of the XML tags and place into the model, you will need
to traverse the XML structure just as you would with XPath/XQuery. A
previous post shows how to do this for a couple of your XML tags.
Follow those examples to get the rest.
-- Scott
On Feb 23, 12:45 pm, sue <vk.ontolog...@gmail.com> wrote:
> Hi,
> Thank you for guidance. I am able to catch up little bit.
> The following query works great when selecting Abstract Text.
> SELECT ?doc ?abstract
> WHERE {
> ?doc a :Abstract .
> ?doc composite:child ?absText .
> ?absText composite:child ?txtNode .
> ?txtNode sxml:text ?abstract
>
> }
>
> One question here though, the variables ?doc, ?absText ?txtNode are user
> defined or its predefine (XML tags) ?
>
> My main goal is to convert the XML file into CSV or an Excel file (Export
> the data into Excel file).
>
> I was wondering in order to select all data from the XML file the following
> query should be good
>
> SELECT ?a ?b ?c
> WHERE {
> ?a ?b ?c}
>
> *or *
> Do I have to type all the variables in where clause like
>
> SELECT *
> WHERE {
> ?abstract
> ?abstractText
> ?author
> ?article
> (and so on)
>
> }
>
> Pls guide :)
> Thank you!!
> On Mon, Feb 22, 2010 at 12:12 PM, Scott Henninger <
>
> > On Feb 22, 10:22 am, Scott Henninger <shennin...@topquadrant.com> <shennin...@topquadrant.com>
> > wrote:
>
> > Sue; There are quite a few issues here. It's a common example and
> > I'd like to turn this into an example for our Web page (http://www.topquadrant.com/products/SPARQLMotion.html) Would that be OK with
> > you?
>
> > Let's start with Semantic XML. See Help > Import and Export >
> > Creating, Importing, Querying, Saving XML documents with Semantic XML
>
> > Semantic XML applies a default RDF form to XML files. Each XML
> > element/tag name is mapped into an OWL class, attributes are mapped to
> > OWL datatype properties, parent-child relationships between the XML
> > elements are expressed with composite:child, composite:index is used
> > to order sibling tags, etc. (see the Help file).
>
> > Can I get you to clarify what you mean by "Example is a sample from
> > the google: " and the purpose of the SPARQL query. I.e. is the query
> > of the form you would like to transform the XML into?
>
> > As I said this is a nice example, on a common topic, and I'd like to
> > step through this as a mini-tutorial in a series of posts. Next will
> > be on extracting data from the XML file.
>
> > -- Scott
>
> > On Feb 21, 11:22 pm, sue <vk.ontolog...@gmail.com> <vk.ontolog...@gmail.com> wrote:
> > topbraid-composer...@googlegroups.com<topbraid-composer-users%2Bunsu...@googlegroups.com>
-- Scott
On Feb 23, 1:13 pm, sue <vk.ontolog...@gmail.com> wrote:
> Hi,
> I came across one more post on conversion (but from RDF to CSV) and it seems
> the attached image is most likely what I am looking for, but I am not sure
> whether it works for XML conversions ?
>
> I can set the "root folder" which contains my hundreds of XML files and then
> it "Iterates over file" and "imports to ??" and "creates spreadsheet" and
> "exports to text"
>
> Again the challenge I see here is, in general while working with a single
> XML file ( I usually import it to the folder on workspace and then
> rightclick on the file and open with "TopBraid (Semantic XML Documents)")
> how does the same thing will work if I set up a root folder which has all my
> XML files?
>
> I hope I am on right track and hope this isn't too noobie of a question.
> Pls Guide :)
> Thanks
> Sue
>
> On Tue, Feb 23, 2010 at 12:45 PM, sue <vk.ontolog...@gmail.com> wrote:
> > Hi,
> > Thank you for guidance. I am able to catch up little bit.
> > The following query works great when selecting Abstract Text.
> > SELECT ?doc ?abstract
> > WHERE {
> > ?doc a :Abstract .
> > ?doc composite:child ?absText .
> > ?absText composite:child ?txtNode .
> > ?txtNode sxml:text ?abstract
> > }
>
> > One question here though, the variables ?doc, ?absText ?txtNode are user
> > defined or its predefine (XML tags) ?
>
> > My main goal is to convert the XML file into CSV or an Excel file (Export
> > the data into Excel file).
>
> > I was wondering in order to select all data from the XML file the following
> > query should be good
>
> > SELECT ?a ?b ?c
> > WHERE {
> > ?a ?b ?c
> > }
> > *or *
> >> On Feb 22, 10:22 am, Scott Henninger <shennin...@topquadrant.com> <shennin...@topquadrant.com>
> >> wrote:
>
> >> Sue; There are quite a few issues here. It's a common example and
> >> I'd like to turn this into an example for our Web page (http://www.topquadrant.com/products/SPARQLMotion.html) Would that be OK with
> >> you?
>
> >> Let's start with Semantic XML. See Help > Import and Export >
> >> Creating, Importing, Querying, Saving XML documents with Semantic XML
>
> >> Semantic XML applies a default RDF form to XML files. Each XML
> >> element/tag name is mapped into an OWL class, attributes are mapped to
> >> OWL datatype properties, parent-child relationships between the XML
> >> elements are expressed with composite:child, composite:index is used
> >> to order sibling tags, etc. (see the Help file).
>
> >> Can I get you to clarify what you mean by "Example is a sample from
> >> the google: " and the purpose of the SPARQL query. I.e. is the query
> >> of the form you would like to transform the XML into?
>
> >> As I said this is a nice example, on a common topic, and I'd like to
> >> step through this as a mini-tutorial in a series of posts. Next will
> >> be on extracting data from the XML file.
>
> >> -- Scott
>
> >> On Feb 21, 11:22 pm, sue <vk.ontolog...@gmail.com> <vk.ontolog...@gmail.com> wrote:
> >> topbraid-composer...@googlegroups.com<topbraid-composer-users%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/topbraid-composer-users?hl=en.
>
>
>
> CreateReportSpreadsheets.png
> 28KViewDownload
To unsubscribe from this group, send email to topbraid-composer...@googlegroups.com.
--
Hi Sue,
You need to walk the graph. No unions are necessary. Try this:
SELECT ?abstractTextField ?titleText ?ISSNText
WHERE {?article a :Article.
?abstract a :Abstract .
?article composite:child ?abstract.
?abstract composite:child ?abstractText.
?abstractText composite:child ?abstractTextNode.
?abstractTextNode sxml:text ?abstractTextField.
?article composite:child ?journal.
?ISSN a :ISSN .
?journal composite:child ?ISSN.
?ISSN composite:child ?ISSNNode.
?ISSNNode sxml:text ?ISSNText.
?article composite:child ?title.
?title a :ArticleTitle.
?title composite:child ?titleNode.
?titleNode sxml:text ?titleText.
}
A couple of techniques could help to understand this. For example, pick an instance of Article in TBC and expand the nodes (purple diamonds) to traverse the relationships as shown below. You can also look at Associations tree to see the same hierarchy. Select composite:child property, right click and pick “Show in Associations View”.
Regards,
Irene
So the structure you have is connected to the tag <Article> and you need to
traverse the tree from that point to associate the data with each
individual article. Note that issn is inside of the journal node, so you
need to traverse that part of the tree as well.
I have attached a graph of the structure from the Graph view. It takes a
bit to choose just the nodes you want, but if you produce this graph and
click on "Generate SPARQL from the Current Graph" (orange star on TOP of
Graph view), a SPARQL query will be produced that does most of what you
want - all but the text in fact.
Also the following query does what you want I believe. The key is to build
a graph (from triples) in the SPARQL query that matches the data you want.
SELECT ?ArticleTitle ?abstract ?ISSNIssnType
WHERE {
?article a :Article .
?telem a :ArticleTitle .
?article composite:child ?telem .
?telem composite:child ?articleTxt .
?articleTxt sxml:text ?ArticleTitle .
?absNode a :Abstract .
?article composite:child ?absNode .
?absNode composite:child ?absText .
?absText composite:child ?txtNode .
?txtNode sxml:text ?abstract .
?jnode a :Journal .
?article composite:child ?jnode .
?issn a :ISSN .
?jnode composite:child ?issn .
?issn composite:child ?IssnTxt .
?IssnTxt sxml:text ?ISSNIssnType .
}
-- Scott
Original Message:
-----------------
From: sue vk.ont...@gmail.com
Date: Thu, 4 Mar 2010 11:43:00 -0600
Hi All,
topbraid-composer...@googlegroups.com<topbraid-composer-users
%2Bunsu...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/topbraid-composer-users?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"TopBraid Composer Users" group.
To post to this group, send email to
topbraid-co...@googlegroups.com.
To unsubscribe from this group, send email to
topbraid-composer...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/topbraid-composer-users?hl=en.
--------------------------------------------------------------------
myhosting.com - Premium Microsoft® Windows® and Linux web and application
hosting - http://link.myhosting.com/myhosting
I am new to this group and I am also working on something similar XML
and RDF files. Well lot of information is provided and seems quite
helpful.
Well to add up to the questions.Traversing seems easy but the other
tags which has list looks challenging.
Ex: In the same file Publisher.xml there are Article List, History,
PublicationTypeList, AuthorList and others.
So for a record there can be more than 1 author, every record has
different values in Author list. So the same traversing will be
helpful?
I don't think its displaying the desired output.
SELECT ?ISSNValue ?LastNameValue ?ForeNameValue ?InitialsValue
WHERE {
?article a :Article.
?AuthorList a :AuthorList.
?article composite:child ?AuthorList.
?AuthorList composite:child ?AuthorValid.
?AuthorValid composite:child ?LastName.
?LastName composite:child ?LastNameNode.
?LastNameNode sxml:text ?LastNameValue.
?AuthorValid composite:child ?ForeName.
?ForeName composite:child ?ForeNameNode.
?ForeNameNode sxml:text ?ForeNameValue.
?AuthorValid composite:child ?Initials.
?Initials composite:child ?InitialsNode.
?InitialsNode sxml:text ?InitialsValue.
?ISSN a :ISSN .
?article composite:child ?journal.
?journal composite:child ?ISSN.
?ISSN composite:child ?ISSNNode.
?ISSNNode sxml:text ?ISSNValue.
}
Is there anything I am missing ?
Thanks, Andy
On Feb 21, 11:22 pm, sue <vk.ontolog...@gmail.com> wrote:
> Publisher.xml
> 39KViewDownload
<Traversing seems easy but the other tags which has list looks
challenging>
One nice thing about XML is that it is very regular. Everything is in
the tree, including data and attributes. All of this is captured in
Semantic XML.
In your case the problem is that you're not selecting a match for
<LastName>, etc. in the "?AuthorValid composite:child ?LastName.", so
you get all of them. To get this you can use the same pattern that
was used to get the others - ask for a member of the class and match
that. So for the last name match, you'd use:
?AuthorList a :AuthorList.
?article composite:child ?AuthorList.
?AuthorList composite:child ?AuthorValid.
?LastName a :LastName .
?AuthorValid composite:child ?LastName.
?LastName composite:child ?LastNameNode.
?LastNameNode sxml:text ?LastNameValue.
Same kind of pattern for the ForeName and Initials.
-- Scott
The first is creating a SPIN function. Notice how in these XML
queries we're always doing the following to get the text node:
?node composite:child ?textnode .
?textnode sxml:text ?txt.
This can be placed in a SPIN function and called as a getElemText()
function. To do this, create a SPIN file (New... SPIN File). Import
the .xml file - the easiest way to do this is to drag-and-drop
the .xml file into the imports view. Composer will recognize the XML
file and automatically convert to Semantic XML triples. Note the
namespace prefix though. Instead of :Article, it will be something
like Publisher:Article.
Next find the class named spin:Modules, open its subclasses, and
create a subclass of spin:Functions named getElemText. This creates
the name of a SPIN function.
We'll pass an element resource to this function and return the value
of the element tag. For example, if we pass the first <ArticleTitle>
tag in Publisher.xml, we would get "A proton NMR relaxation study..."
in return.
For the return value, set spin:returnType for your class (getElemText)
to xsd:string.
For the argument, we pass a property through the spin:constraint.
Drag-and-drop a property (use sp:arg1) into the spin:constraint
property for your SPIN function. A wizard will appear for
spl:Argument. Just select OK to create the constraint.
In the spin:body property, add the query:
SELECT ?txt
WHERE {
?arg1 composite:child ?textnode .
?textnode sxml:text ?txt .
}
Note that we pass in the element tag's resource in ?arg1 and return
the value ?txt.
Now this function can be used in queries for this model using a LET
statement to bind the return value to a variable. For example the
original query for getting the article title can be shortened a bit:
SELECT ?ArticleTitle ?abstract ?ISSNIssnType
WHERE {
?article a Publisher:Article .
?telem a Publisher:ArticleTitle .
?article composite:child ?telem .
LET (?ArticleTitle := :getElemText(?telem))
# ?telem composite:child ?articleTxt .
# ?articleTxt sxml:text ?ArticleTitle .
...
}
I commented out the two lines from the original query that are now
abstracted into the function (note the pattern is indeed the same).
Next step to apply the same kind of principle in a custom Magic
Property that will allow us to reduce our query to one SPARQL
statement for each tag we want to match...
-- Scott
On Mar 5, 12:57 pm, Andy <jewel.s...@gmail.com> wrote: