Re: [PyWrapper-devel] Valid response model
Status: Alpha
Brought to you by:
jatorre
From: Roger H. <ro...@hy...> - 2006-12-18 17:55:00
|
Thanks Markus, I'll have a look at it over the next few days - still have shopping =20 to do myself. I was presuming that the schemas would have to be modified in some =20 way to produce usable output models. I'll get the code and have a =20 hack at the schemas to see what I can get going. Many thanks and Merry Christmas, Roger On 18 Dec 2006, at 16:04, Markus D=F6ring wrote: > Roger, > I've updated pywrapper in the SVN trunk. Your example =20 > test1_broken.xsd works fine now. I had to change some methods in =20 > the structure_handler.py and I hope I didnt break anything. I dont =20 > think so, but as you might know we are still missing comfortable =20 > unit tests, so all I can do is run through some schemas/models I =20 > know they should work (like abcd and tcs). and that test is =20 > successfully acomplished. > > But if I run your previous complex real world example I still got =20 > an error. I found that you are using a recursive construct =20 > TaxonName that can be a link or another TaxonName. This is not =20 > supported by pywrapper at the moment. When encountering such =20 > constructs the software should give out a warning and ignore the =20 > recursion (just work with it as if there was no further reference). =20= > But right now it raises an error and refuses to work with that =20 > model. I still need some christmas presents so I cant continue on =20 > that, maybe something for the coding fest - together with the yet =20 > unsopported "group" tag you mentioned earlier (shouldnt be too hard). > > Anyway you should be able to continue with your RDF test. Just =20 > avoid recursions and also the xml schema "group" tag. > And please keep us informed about the results! > > Markus > > > > > On Dec 15, 2006, at 5:32 PM, Roger Hyam wrote: > >> 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 =20 >> for 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?=20 >> op=3Dschema&location=3Dhttp://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?=20 >> op=3Dschema&location=3Dhttp://rs.tdwg.org/ontology/voc/xsd/=20 >> 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 =20 >> in structure_handler.py it doesn't mention namespace (unlike the =20= >> _buildElement attribute) and it confuses me as it seems to pass =20 >> the 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 =20 >> to fix this in minutes rather than my hours and would probably =20 >> create 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 =20 >>> implementation. I couldnt find any existing schema parser out =20 >>> there, honestly. So as you can imagine this is a pretty tough job =20= >>> and I have tried it with many different schemas and progressed in =20= >>> implementing xml schema, but still dont support all of it (for =20 >>> example references 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 =20 >>> complaints that the attribute http://rs.tdwg.org/ontology/voc/=20 >>> TaxonName#/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 =20 >>> should expand rdf:about into the full qualified name http://=20 >>> www.w3.org/1999/02/22-rdf-syntax-ns#about and hopefully find the =20 >>> global 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. =20 >>>> Here 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 =20 >>>> so I *think* the schema is OK. The parser is handling the import =20= >>>> of TaxonName.xsd OK. Is it a problem with attributes? Is it a =20 >>>> bug or a known limitation or an error in my schema? >>>> >>>> The are also problems with the group element but I can always =20 >>>> work 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 =20 >>>> to share your >>>> opinions on IT & business topics through brief surveys - and =20 >>>> earn 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 >>> >> >> ---------------------------------------------------------------------=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 > |