From: Tom M. <Tom@Malcolmson.com> - 2005-04-15 16:34:23
Attachments:
examples_ver.4.p5.xml
|
I'm new to RST. I am hoping to use it to create XML, but not DocUtils XML. I'm creating a TEI (text encoding initiative) bibliography, and I think that RST might be ideal for this. Any comments or suggestions? I've attached the latest version of the TEI P5 bibliograpy samples. This is the sort of stuff that I want to generate. If you are interested, here's a couple links: TEI homepage http://www.tei-c.org/ The TEI P5 BiblItem (bibliographic citation) declaration: http://www.tei-c.org/P5/Guidelines/ref-BIBLITEM.html Thanks, Tom. |
From: Felix W. <Fel...@gm...> - 2005-04-21 22:18:15
|
Tom Malcolmson wrote: > I'm new to RST. I am hoping to use it to create XML, but not DocUtils > XML. I'm creating a TEI (text encoding initiative) bibliography, and > I think that RST might be ideal for this. From what I can see from the attached XML file, it does not resemble a document at all, so that's not really what reST is designed for. However, while reST is not able to do something like that natively, you may be able to leverage reST's field list or definition list constructs (for details please refer to <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html>): Using field lists: $ rst2pseudoxml.py --no-doc-info :foreName: :choice: :abbr: T :expan: Thomas ^D (press Ctrl+Z under Windows) <document source="<stdin>"> <field_list> <field> <field_name> foreName <field_body> <field_list> <field> <field_name> choice <field_body> <field_list> <field> <field_name> abbr <field_body> <paragraph> T <field> <field_name> expan <field_body> <paragraph> Thomas Using definition lists: $ rst2pseudoxml.py foreName choice abbr : type=initial T expan Thomas ^D (press Ctrl+Z under Windows) <document source="<stdin>"> <definition_list> <definition_list_item> <term> foreName <definition> <definition_list> <definition_list_item> <term> choice <definition> <definition_list> <definition_list_item> <term> abbr <classifier> type=initial <definition> <paragraph> T <definition_list_item> <term> expan <definition> <paragraph> Thomas What you are seeing there is the node tree as it is internally used by Docutils and as it would be passed on to, say, the HTML writer. If you have some knowledge of the Python language, you could take that node tree (i.e. not the pseudo-XML output you're seeing above but the genuine Python objects) and transform it into your format. You could also use rst2xml.py and read and process the XML output using your favorite language. BTW, David, is there an easy possibility to get the node tree from a given reST document? If not, do you think it would be reasonable to add a "passthrough" writer which just returns the document node? -- For private mail please ensure that the header contains 'Felix Wiemann'. http://www.ososo.de/ |
From: David G. <go...@py...> - 2005-04-22 00:40:20
Attachments:
signature.asc
|
[Felix Wiemann] > BTW, David, is there an easy possibility to get the node tree from a > given reST document? Yes, just write a simple Writer: from docutils import writers class Writer(writers.Writer): def translate(self): # do something with self.document docutils.io.NullOutput can be used as a dummy destination. > If not, do you think it would be reasonable to add a "passthrough" > writer which just returns the document node? Sure. But what would the client code do with it? Whatever it does, could be done by a custom Writer too, which would probably be clearer and more direct. -- David Goodger <http://python.net/~goodger> |
From: Tom B. <to...@ci...> - 2005-04-22 12:25:45
|
On Thursday 21 April 2005 20:40, David Goodger wrote: > [Felix Wiemann] > > > BTW, David, is there an easy possibility to get the node tree from a > > given reST document? > > Yes, just write a simple Writer: ... > > If not, do you think it would be reasonable to add a "passthrough" > > writer which just returns the document node? > > Sure. But what would the client code do with it? Whatever it does, > could be done by a custom Writer too, which would probably be clearer > and more direct. It would be somewhat useful for those Pythonistas who are playing with Docutils and custom writers for the first time. Maybe a good thing to throw into examples.py? Often, when I start playing with new code, the first thing I do is write a minimal program that I can invoke with python -i so that I can then interactively inspect the module's data structures. If docutils already had such a thing, so much the better! :-) -- Tom Bryan <to...@ci...> Test Information Systems > Central Engineering Services Cisco Systems > USA > NC > RTP |
From: David G. <go...@py...> - 2005-04-23 19:29:23
Attachments:
signature.asc
|
[Tom Bryan] > It would be somewhat useful for those Pythonistas who are playing > with Docutils and custom writers for the first time. Maybe a good > thing to throw into examples.py? Yes, good idea. I just added docutils.writers.null, a do-nothing Writer, and docutils.examples.internals, which returns the document tree and publisher object. Explore at will :-) -- David Goodger <http://python.net/~goodger> |
From: Tom B. <to...@ci...> - 2005-04-22 12:30:10
|
On Thursday 21 April 2005 18:18, Felix Wiemann wrote: > Tom Malcolmson wrote: > > I'm new to RST. I am hoping to use it to create XML, but not DocUtils > > XML. I'm creating a TEI (text encoding initiative) bibliography, and > > I think that RST might be ideal for this. > > From what I can see from the attached XML file, it does not resemble a > document at all, so that's not really what reST is designed for. But, IIRC, record sets is what YAML was designed for. I like RST, but for this application, you may want to check out YAML. http://www.yaml.org/ -- Tom Bryan <to...@ci...> Test Information Systems > Central Engineering Services Cisco Systems > USA > NC > RTP |