xmlsparqldbpediaxformsxsltforms

XSLTForms / XForms - Namespaces in instance data?


What am I doing wrong here - my XForms data source is a SPARQL result - and I can get at it using the following XPATH:

<bind id="bnd_results"  nodeset="instance('sparql')/*/*/*"/>

But I can't seem to get this to work without using the '*' wildcards. It appears to related to the namespace of instance data.

    <?php
    header('Content-Type: text/xml; charset=utf-8'); 
    if (isset($_GET['debug'])) { $debug="yes"; } else { $debug="no"; }
?>
<?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?>
<?xsltforms-options debug="<?=$debug?>"?>
<?php
    $sparqlep="https://dbpedia.org/sparql?query=";
    $sparql=<<<SPARQL
SELECT DISTINCT(?linkedPerson) WHERE {
?s rdfs:label           'World Wide Web Consortium'@en;
        foaf:isPrimaryTopicOf ?wikipage.
?linkedPerson rdf:type              dbo:Person,
                                    foaf:Person;
              foaf:isPrimaryTopicOf ?linkedwikipage. 
{ ?s ^dbo:wikiPageWikiLink ?linkedPerson.} UNION { ?s dbo:wikiPageWikiLink ?linkedPerson. }}
LIMIT 100
SPARQL;
    $url=$sparqlep . rawurlencode($sparql);
?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:sparql="http://www.w3.org/2005/sparql-results#"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd">
<head>
<model xmlns="http://www.w3.org/2002/xforms">
    <instance id="sparql" src="<?=$url?>"/>  
    <instance id="default">
         <data xmlns="">
            <selected/>
         </data>
    </instance>
         <bind id="bnd_results"  nodeset="instance('sparql')/*/*/*"/>
    <bind id="bnd_sel"  nodeset="instance('default')/selected"/>
</model>
</head>
<body>
    <details>
        <summary>SPARQL query</summary>
        <code> <?=$sparql?> </code>
    </details>

    <group xmlns="http://www.w3.org/2002/xforms">
        <label>Selected:</label>
        <output bind="bnd_sel"/>
        <select1  appearance="full" bind="bnd_sel">
            <itemset bind="bnd_results">
                <label ref="."/>
                <value ref="."/>
            </itemset>
        </select1>
    </group>

</body>
</html>

Example output


Solution

  • Even if it is an extension for XPath 1.0, XSLTForms allows to specify any prefix with "*" such as in "*:myelement".

    It is also possible to declare a prefix within the form so it can be used in XPath expressions.