Hi all,

I've setup a small test case and was trying to see the effect of the 
copy-namespaces instruction.
What I am trying to achieve is to have the root tag (in this case rdf:RDF) 
declare all used namespaces so that the result of the XQuery becomes much  
smaller for big result sets.

Any pointers on how to achieve this?

Thx in advance,
Robby


*******************************************************************
declare namespace convert2rdf = "http://www.nxp.com/convert2rdf";;

declare copy-namespaces preserve, inherit;

declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";;
declare namespace skos="http://www.w3.org/2004/02/skos/core#";;
declare namespace foaf="http://xmlns.com/foaf/0.1/";;
declare namespace nxp="http://purl.org/nxp/schema/v1/";;

declare function convert2rdf:basicType($product as element(product)) {
  <rdf:RDF>{convert2rdf:basicTypeRaw($product)}</rdf:RDF>
};

declare function convert2rdf:basicTypeRaw($product as element(product)) {
    let $btn := data($product/name)
    return
    <rdf:Description rdf:about="http://data.nxp.com/basicTypes/{$btn}";>
      <rdf:type rdf:resource="http://purl.org/nxp/schema/v1/BasicType"/>
      <skos:prefLabel 
xml:lang="en-us">{data($product/description)}</skos:prefLabel>
      <foaf:homepage rdf:resource="http://www.nxp.com/pip/{$btn}"/>
      <nxp:typeNumber>{$btn}</nxp:typeNumber>
    </rdf:Description>
};

let $product :=
  <product>
    <name>PH3330L</name>
    <description>N-channel TrenchMOS logic level FET</description>
  </product>
  
(:
return convert2rdf:basicType($product)
:)

(:
return convert2rdf:basicTypeRaw($product)
:)

********************** output from  convert2rdf:basicType($product) 
*************************
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
  <rdf:Description rdf:about="http://data.nxp.com/basicTypes/PH3330L";>
    <rdf:type rdf:resource="http://purl.org/nxp/schema/v1/BasicType"/>
    <skos:prefLabel xmlns:skos="http://www.w3.org/2004/02/skos/core#"; 
xml:lang="en-us">N-channel TrenchMOS logic level FET</skos:prefLabel>
    <foaf:homepage xmlns:foaf="http://xmlns.com/foaf/0.1/"; 
rdf:resource="http://www.nxp.com/pip/PH3330L"/>
    <nxp:typeNumber 
xmlns:nxp="http://purl.org/nxp/schema/v1/";>PH3330L</nxp:typeNumber>
  </rdf:Description>
</rdf:RDF>

********************** output from  convert2rdf:basicTypeRaw($product) 
*************************
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; 
rdf:about="http://data.nxp.com/basicTypes/PH3330L";>
  <rdf:type rdf:resource="http://purl.org/nxp/schema/v1/BasicType"/>
  <skos:prefLabel xmlns:skos="http://www.w3.org/2004/02/skos/core#"; 
xml:lang="en-us">N-channel TrenchMOS logic level FET</skos:prefLabel>
  <foaf:homepage xmlns:foaf="http://xmlns.com/foaf/0.1/"; 
rdf:resource="http://www.nxp.com/pip/PH3330L"/>
  <nxp:typeNumber 
xmlns:nxp="http://purl.org/nxp/schema/v1/";>PH3330L</nxp:typeNumber>
</rdf:Description>


_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to