Re: [PyWrapper-devel] Valid response model
Status: Alpha
Brought to you by:
jatorre
From: Roger H. <ro...@td...> - 2006-12-15 16:33:00
|
Thanks for the kind words Markus. I'm glad some one is glad I am =20 trying to do this ;) I hope it doesn't end up with too much work for =20 you. I have narrowed down this problem to a simple test case. This is a more simple XSD with a single import and it works fine: http://localhost:8080/pywrapper/pywrapper?op=3Dschema&location=3Dhttp://=20= rs.tdwg.org/ontology/voc/xsd/test1.xsd The second version is just the same but includes the use of an =20 attribute reference in the imported file: http://localhost:8080/pywrapper/pywrapper?op=3Dschema&location=3Dhttp://=20= rs.tdwg.org/ontology/voc/xsd/test1_broken.xsd and it doesn't work! Looking at the logs The error message is "PyWrapperError: Global element reference 'http://rs.tdwg.org/=20 ontology/voc/Test2#/rdf:about' missing" But we have a slightly earlier log message saying 2006-12-15 16:14:14,789 - DEBUG from pywrapper.model: =20 self._globalRefs=3D[u'http://www.w3.org/1999/02/22-rdf-syntax-ns#/=20 @about', u'http://rs.tdwg.org/ontology/voc/Test2#/MyElement', =20 u'http://www.w3.org/1999/02/22-rdf-syntax-ns#/RDF', u'http://=20 www.w3.org/1999/02/22-rdf-syntax-ns#/MyRdfString'] So it looks to me like it is just getting the namespace of the =20 attribute reference wrong and so not finding it in the globalRefs =20 look up. It does it right for the element but not for the attribute. Looking at the code for _buildAttribute(self, attrs) on line 269 in =20 structure_handler.py it doesn't mention namespace (unlike the =20 _buildElement attribute) and it confuses me as it seems to pass the =20 type as the namespace to the Attribute object it creates. Now this code all looks like clever stuff and I don't want to go =20 trying to fix anything when I don't really know what I am doing - =20 though I will have a go if no one else wants to. You may be able to =20 fix this in minutes rather than my hours and would probably create =20 fewer bugs . It may be that I am doing something bad in the XSD although I am =20 pretty confident I am OK on that. Would once again be grateful for you comments, Roger On 14 Dec 2006, at 10:48, Markus D=F6ring wrote: > Hi Roger, > that's exactly what we were all thinking of doing for some time =20 > already. Good finally someone DOES it! > The xml schema parser inside pywrapper is a custom implementation. =20 > I couldnt find any existing schema parser out there, honestly. So =20 > as you can imagine this is a pretty tough job and I have tried it =20 > with many different schemas and progressed in implementing xml =20 > schema, but still dont support all of it (for example references =20 > and patterns). > > Well, and your RDF schema is honestly the most complex I've seen =20 > that was fed to pywrapper. > So I tried to trace the problem and as you see pywrapper complaints =20= > that the attribute http://rs.tdwg.org/ontology/voc/TaxonName#/=20 > rdf:about is being referenced, but is nowhere defined. > pywrapper expands all namespace prefixes into the full namespace. =20 > So in this case http://rs.tdwg.org/ontology/voc/TaxonName# is the =20 > targetnamespace of the imported lib/TaxonName.xsd schema file. So =20 > in there I suspect is a reference to rdf:about, which pywrapper =20 > thinks is an attribute name. I think this is because I cant find =20 > anywhere the prefix rdf: being defined properly. I suspect oXygen =20 > and alike know what rdf: means. So try to add a namespace =20 > declaration to the schemas (for owl etc too). Then pywrapper should =20= > expand rdf:about into the full qualified name http://www.w3.org/=20 > 1999/02/22-rdf-syntax-ns#about and hopefully find the global =20 > declaration of rdf:about in the lib/rdf.xsd schema. > > But again, I think I've never tried a schema with that many =20 > namespaces and imports so I keep my fingers crossed... > > Please let me know what happens! > Markus > > > > On Dec 13, 2006, at 11:29 PM, Roger Hyam wrote: > >> Hi All, >> >> I am looking at what TAPIR output models I could use with =20 >> PyWrapper. I have developed XML Schemas that will help produce =20 >> valid RDF instance data for a simple OWL ontology. Here is an =20 >> example: >> >> http://rs.tdwg.org/ontology/voc/xsd/TaxonName/schema.xsd >> >> If you open this link in OxygenXML or Spy you can expand all the =20 >> nodes and create instance documents that look like valid RDF. Here =20= >> is an example instance document: >> >> http://rs.tdwg.org/ontology/voc/xsd/TaxonName/template.xml >> >> So the plan would be to use the schema above (or something =20 >> similar) as the structure in an output model so that a TAPIR =20 >> response could be a valid semantic web document and a LSID =20 >> metadata response. A complete LSID authority would need very =20 >> little code on top of this. >> >> The downside is that these schemas are complex because of the =20 >> number of imports required to support the different namespaces =20 >> involved. >> >> Anyhow. The first step was to check that PyWrapper would parse =20 >> schemas like the one above so I did this: >> >> http://localhost:8080/pywrapper/pywrapper?=20 >> op=3Dschema&location=3Dhttp://rs.tdwg.org/ontology/voc/xsd/TaxonName/=20= >> schema.xsd >> >> on my local machine and got >> >> "The models response structure is invalid: Global element =20 >> reference 'http://rs.tdwg.org/ontology/voc/TaxonName#/rdf:about' =20 >> missing" >> >> I am not sure why I get this as OxygenXML doesn't have a problem =20 >> with expanding the links and validating the rdf:about attribute so =20= >> I *think* the schema is OK. The parser is handling the import of =20 >> TaxonName.xsd OK. Is it a problem with attributes? Is it a bug or =20 >> a known limitation or an error in my schema? >> >> The are also problems with the group element but I can always work =20= >> round this by just repeating the element. >> >> Any ideas on the rdf:about problem would be most welcome. >> >> Many thanks, >> >> Roger >> >> >> >> >> >> **************************************** >> Roger Hyam <ro...@td...> >> Biodiversity Information Standards >> **************************************** >> >> >> ---------------------------------------------------------------------=20= >> ---- >> Take Surveys. Earn Cash. Influence the Future of IT >> Join SourceForge.net's Techsay panel and you'll get the chance to =20 >> share your >> opinions on IT & business topics through brief surveys - and earn =20 >> cash >> http://www.techsay.com/default.php?=20 >> page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV___________________________= ____=20 >> ________________ >> PyWrapper-devel mailing list >> PyW...@li... >> https://lists.sourceforge.net/lists/listinfo/pywrapper-devel > |