Re: [xml] Generating XML from Schema definitions (again, sorry) [SEC=UNCLASSIFIED]



Hi Callum,

I don't think that I have seen a response about how your work on this thread
is going.  Have you cracked the code yet?  Did you try the complex ISO  TC
211 XSDs for your creation of XML?  Or has it just been too hard to get XML
out of the XSDs?

Thanks.


John

-----Original Message-----
From: Hockaday John 
Sent: Thursday, 9 August 2007 1:54 PM
To: xml gnome org
Cc: 'Callum Gibson'
Subject: RE: [xml] Generating XML from Schema definitions 
(again, sorry) [SEC=UNCLASSIFIED]


Callum,

Do I read this thread right?  That is, you can create an XML 
document instance for a W3C XML Schema?  Not only that but 
your code resolves import statements and include statement?

If this is the case then I'm all for using it on the ISO 
19139 XSDs!  Alternatively you could use this very complex 
set of XSDs to test your code.  ;--)  The locations of the 
XSDs is http://www.isotc211.org/2005/ and the root XSD is 
http://www.isotc211.org/2005/gmd/gmd.xsd 

Does your code also create potential attributes in the elements?

Thanks.


John

-----Original Message-----
From: xml-bounces gnome org [mailto:xml-bounces gnome org] On 
Behalf Of Callum Gibson
Sent: Thursday, 9 August 2007 12:34 PM
To: xml gnome org
Subject: Re: [xml] Generating XML from Schema definitions 
(again, sorry)


Hi,

I just wanted to give an update on where I'm at and have it 
recorded for
the archive in case anyone else needs to do the same thing.

On 27 Jul 18:50, callum_r_gibson yahoo com au wrote:
}On 27 Jul 03:45, Daniel Veillard wrote:
}}  We don't really have what you expect and for a variety 
of reasons:
}}    - first you can't systematically derive one kind of 
document from
}}      a schemas, it's like trying to derive one string from 
a complex
}}      regexp. You need schemas or regexps preceisely because your
}}      document or string can mute into various ways. It's a 
completely
}}      open problem if looked from a generic POV.
}I understand what you mean - I assume you're referring to 
optional and
}repeating elements, for example. However I would be using 
my internal
}mapping of xpaths (or something similar) to drive which of 
those elements
}I would need to generate. So I guess I would be looking to use a
}combination of the schema and my own internal data mapping 
table. That
}should allow a specific document to be output. For example, if you
}traverse into a non-optional element and could find no match
}definition/xpath in the data mapping table or data 
callback then that
}would obviously be an error. Alternatively, you could 
default to null or
}empty values.

I've determined I can do what I want with only minimal exposure of
the internals of the schemas code. I do need to use 
schemasInternals.h
but apart from that the only actual changes to core libxml 
code is to
add accessor functions to retrieve the doc and schema 
pointers associated
with an imported schema.

In other words, what I'm doing is traversing the xsd schema 
doc and when
I come across a reference to an imported type or element I 
lookup that
namespace in the schemasImports hash and get the 
xmlSchemaImport struct
which contains the imported schema definition and it's 
document tree.

I then basically have a state parser which operates on the 
xsd document
tree and switches to the imported document tree as necessary. 
I use hints
from my own application data mapping to determine the resolution of
elements such as abstract types, choices, optional elements 
and so on.
I've successfully done a test traversal of the schema I'm 
interested in
and printed out the xml document tree, but I still need to work on
actual mapping of data values.

As I've explained previously, I also want a nice generic way 
to provide
those hints to my xsd parser (maybe with a "decision" 
callback). I'll
probably use the parser to generate a template xml doc, with 
which I can
then fill in the values using callbacks, for example. I'll 
probably need
to (ab)use the _private pointer for that bit.

The changes I made were to add declarations in 
schemasInternals.h for
two new functions in xmlschemas.c:

XMLPUBFUN xmlDocPtr XMLCALL             
xmlSchemaImportGetDoc(void *imp);
XMLPUBFUN xmlSchemaPtr XMLCALL          
xmlSchemaImportGetSchema(void *imp);

I also had to include xmlschemas.h in schemasInternals.h to 
ensure the
definition of xmlSchemaPtr, but I didn't think that was too 
unreasonable
for any other file which was including schemasInternals.h 
anyway. The
rest I can do with public functions.

I love having the source code. Thanks to all libxml 
contributors. :-)

regards,
    Callum

-- 

Callum Gibson @ home

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]