tags:

views:

282

answers:

1

Hi all,

I'm still working on a particular RDF file, but seems that something is not going in the right way for me. The code of my RDF file is the following:

<?xml version = '1.0"?>

<rdf:RDF xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc = "http://purl.org/dc/elements/1.1/"
xmlns:dp = "http://www.telemed.uniud.it/dp/0.1/"
xmlns:dcq = "http://purl.org/dc/qualifiers/1.0/" >


<rdf:Description rdf:about="m021">
 <dc:creator>CAB</dc:creator>
 <dc:title>m021</dc:title>
 <dc:subject></dc:subject>
 <dc:date>null</dc:date>
 <dc:description></dc:description>
 <dc:identifier>1</dc:identifier>
 <dc:relation.requires rdf:resource="./20x/m02120x"/>
 <dc:relation.requires rdf:resource="./10x/m02110x"/>
 <dc:relation.requires rdf:resource="./5x/m0215x"/>
 <dc:relation.requires rdf:resource="./2.5x/m0212.5x"/>
 <dc:relation.requires rdf:resource="preview.jpg"/>
 <dp:resolution rdf:parseType="Resource">
   <dp:unit>micron</dp:unit>
   <dp:x>0.23235294</dp:x>
   <dp:y>0.23046875</dp:y>
 </dp:resolution>
 <dp:objective rdf:parseType="Resource">
   <dp:magnification>20.0</dp:magnification>
   <dp:na>0.6</dp:na>
 </dp:objective>
 <dp:imsize rdf:parseType="Resource">
   <dp:x>316</dp:x>
   <dp:y>236</dp:y>
 </dp:imsize>
</rdf:Description>

<rdf:Description rdf:about="./20x/m02120x">
 <dp:type>plane</dp:type>
 <dp:magnification>20</dp:magnification>
 <dp:matrix rdf:parseType="Resource">
  <dp:xrange>1-103</dp:xrange>
  <dp:yrange>1-86</dp:yrange>
 </dp:matrix>
</rdf:Description>

</rdf:RDF>

I've loaded this file using URLLoader and in my script I'm trying to access some properties. For instance I have to access property dp:x, nested in dp:resolution, nested in rdf:Description and in my mind the right piece of code is:

//assume that 'result:XML' is the variable containing all my RDF and xmlLabel a label

xmlLabel.text = 'test: ' + result.Description.resolution.x;

but this code gives me an empty result.

I tried a different (and not elegant way) to do it passing the following line:

xmlLabel.text = 'test: ' + result.child(0).child(11).child(1);

and this piece of code wokrs, giving me the value 0.23235294 (as expected)

My question is: am I doing something wrong calling the properities? I also tried the "double dot" notation (e.g. result..Description) with no results.

The problem could be that the file I am working on is not a valid XML file? In this case, is there a way to adapt my RDF to a valid XML in order to make it work?

Thank you for your answers

David

+1  A: 

Hi David (yes it's me, cheng :) ). The reason you have empty results is that the tag is specified in a namespace, and you have to specify it when accessing the tag. You can find useful information in this flex tutorial.

Basically you have to declare a namespace variable, like:

var rdf:Namespace = new Namespace ("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
var dp:Namespace = new Namespace ("http://www.telemed.uniud.it/dp/0.1/");

and then use it when accessing nodes, like:

var resolution = result.ref::Description.dp::resolution
cheng81