[xquery-talk] how to copy namespaces to root tag (to avoid repetition)
Robby Pelssers
Robby.Pelssers at nxp.com
Thu Aug 23 05:14:18 PDT 2012
Yeah.. that's a simple approach that will work (was my first approach actually) but it will give me much more maintenance (and typing). To be honest... this really sounds like a hot feature and it's hard to believe this is not supported.
Robby
-----Original Message-----
From: David Lee [mailto:dlee at calldei.com]
Sent: Thursday, August 23, 2012 1:49 PM
To: Robby Pelssers; talk at x-query.com
Subject: RE: [xquery-talk] how to copy namespaces to root tag (to avoid repetition)
I suggest a simpler approach is to simply predecease all namespaces on your root node.
The serializer then will (should) omit redundant namespace declarations on child nodes.
----------------------------------------
David A. Lee
dlee at calldei.com
http://www.xmlsh.org
-----Original Message-----
From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf Of Robby Pelssers
Sent: Thursday, August 23, 2012 7:44 AM
To: talk at x-query.com
Subject: [xquery-talk] how to copy namespaces to root tag (to avoid repetition)
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>
_______________________________________________
talk at x-query.com
http://x-query.com/mailman/listinfo/talk
More information about the talk
mailing list