match interior of XML tag using XSL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dzieciou

    match interior of XML tag using XSL

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

    <j.0:ResultSe t>
    <j.0:solution rdf:parseType=" Resource">
    <j.0:binding rdf:parseType=" Resource">
    <j.0:value>Jo hn Smith</j.0:value>
    <j.0:variable>f name</j.0:variable>
    </j.0:binding>
    <j.0:binding rdf:parseType=" Resource">
    <j.0:variable>x </j.0:variable>
    <j.0:value rdf:resource="h ttp://somewhere/JohnSmith/"/>
    </j.0:binding>
    </j.0:solution>
    <j.0:ResultSe t>

    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.
  • Joe Fawcett

    #2
    Re: match interior of XML tag using XSL

    "dzieciou" <macgaw@mat.uni .torun.pl> wrote in message
    news:8416c258.0 406110434.56a27 e26@posting.goo gle.com...[color=blue]
    > I've used JENA and got the following result in result of query to RDF
    > file:
    >
    > <j.0:ResultSe t>
    > <j.0:solution rdf:parseType=" Resource">
    > <j.0:binding rdf:parseType=" Resource">
    > <j.0:value>Jo hn Smith</j.0:value>
    > <j.0:variable>f name</j.0:variable>
    > </j.0:binding>
    > <j.0:binding rdf:parseType=" Resource">
    > <j.0:variable>x </j.0:variable>
    > <j.0:value rdf:resource="h ttp://somewhere/JohnSmith/"/>
    > </j.0:binding>
    > </j.0:solution>
    > <j.0:ResultSe t>
    >
    > 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.[/color]
    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:styleshe et xmlns:j.0="<the full namespace uri goes here>" ..rest of
    element...

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

    2)
    <xsl:styleshe et 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)


    Comment

    Working...