match interior of XML tag using XSL

D

dzieciou

I've used JENA and got the following result in result of query to RDF
file:

<j.0:ResultSet>
<j.0:solution rdf:parseType="Resource">
<j.0:binding rdf:parseType="Resource">
<j.0:value>John Smith</j.0:value>
<j.0:variable>fname</j.0:variable>
</j.0:binding>
<j.0:binding rdf:parseType="Resource">
<j.0:variable>x</j.0:variable>
<j.0:value rdf:resource="http://somewhere/JohnSmith/"/>
</j.0:binding>
</j.0:solution>
<j.0:ResultSet>

I wish it was transformed with XLS into something like this:

<resultset>
<solution>
<fname>John Smith</fname>
<x>http://somewhere/JohnSmith/</x>
</solution>
</resultset>

The main problem is how to match the interior of XML tag (i.e. fname)
and put it into <fname>. Thxn for any help or suggestion,

Maciek.
 
J

Joe Fawcett

dzieciou said:
I've used JENA and got the following result in result of query to RDF
file:

<j.0:ResultSet>
<j.0:solution rdf:parseType="Resource">
<j.0:binding rdf:parseType="Resource">
<j.0:value>John Smith</j.0:value>
<j.0:variable>fname</j.0:variable>
</j.0:binding>
<j.0:binding rdf:parseType="Resource">
<j.0:variable>x</j.0:variable>
<j.0:value rdf:resource="http://somewhere/JohnSmith/"/>
</j.0:binding>
</j.0:solution>
<j.0:ResultSet>

I wish it was transformed with XLS into something like this:

<resultset>
<solution>
<fname>John Smith</fname>
<x>http://somewhere/JohnSmith/</x>
</solution>
</resultset>

The main problem is how to match the interior of XML tag (i.e. fname)
and put it into <fname>. Thxn for any help or suggestion,

Maciek.
You have two options, the first is to declare the namespace that j.0 refers
to on your document (the above xml is invalid as it does not declare the
namespace)and match using this, the second is to match on local-name only:
1)
<xsl:stylesheet xmlns:j.0="<the full namespace uri goes here>" ..rest of
element...

<xsl:template match="j.0:ResultSet">
<xsl:element name="{local-name()}"></element>

2)
<xsl:stylesheet xmlns:j.0="<the full namespace uri goes here>" ..rest of
element...

<xsl:template match="*[local-name() = 'ResultSet']">
<xsl:element name="{local-name()}"></element>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top