[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] are the regular expressions over xml structure?
- From: Dimitre Novatchev <dnovatchev@gmail.com>
- To: Oleg Parashchenko <olpa@uucode.com>
- Date: Fri, 29 Jun 2012 04:47:29 -0700
> rx = xml_re.compile('''(h1, (not h1)*)''')
> rx.sub('''<section>\0</section>''', xml_doc)
Why would anybody sacrifice the readability, maintainability and
polymorphism/extensibility of XSLT templates for something as ugly,
unreadable and error-prone as this?
Cheers,
Dimitre.
On Fri, Jun 29, 2012 at 1:52 AM, Oleg Parashchenko <olpa@uucode.com> wrote:
> Hello,
>
> are there libraries to work with XML structure using regular expressions?
>
> Something like this, in pseudocode:
>
> rx = xml_re.compile('''(h1, (not h1)*)''')
> rx.sub('''<section>\0</section>''', xml_doc)
>
> If the content of xml_doc was
>
> <x>
> <h1>Heading 1</h1>
> <p>text 1</p>
> <p>text 2</p>
> <h1>Heading 2</h1>
> <p>text 3</p>
> </x>
>
> then the substitution should result in:
>
> <x>
> <section>
> <h1>Heading 1</h1>
> <p>text 1</p>
> <p>text 2</p>
> </section>
> <section>
> <h1>Heading 2</h1>
> <p>text 3</p>
> </section>
> </x>
>
> Any hints are welcome!
>
>
>
> --
> Oleg Parashchenko olpa@ http://uucode.com/
> http://uucode.com/blog/ XML, TeX, Python, Mac, Chess
>
>
> _______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>
--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]