match interior of XML tag using XSL

Discussion in 'XML' started by dzieciou, Jun 11, 2004.

  1. dzieciou

    dzieciou Guest

    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.
    dzieciou, Jun 11, 2004
    #1
    1. Advertising

  2. dzieciou

    Joe Fawcett Guest

    "dzieciou" <> wrote in message
    news:...
    > 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>


    --

    Joe (MVP - xml)
    Joe Fawcett, Jun 11, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    783
    John C. Bollinger
    Jan 27, 2006
  2. Ray Tayek
    Replies:
    3
    Views:
    515
    Ray Tayek
    Nov 30, 2003
  3. Henry Law
    Replies:
    2
    Views:
    86
    Henry Law
    Aug 5, 2006
  4. ccc31807
    Replies:
    15
    Views:
    501
    ccc31807
    Dec 20, 2011
  5. Replies:
    1
    Views:
    94
    Thomas 'PointedEars' Lahn
    Aug 17, 2007
Loading...

Share This Page