[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Text To XML using XSL

Subject: Re: Text To XML using XSL
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 11 Apr 2005 12:24:13 +0100
convert text to xml
> Text
>
> 1. B H. J. Eichler, P. G&#x0123;nter, and D. W. Pohl, <I>Laser-Induced 
> Dynamic Gratings</I> (Springer, Berlin, 1986).
>
> 2. B J. D. Ferry, <I>Viscoelastic Properties of Polymers,</I> 3rd ed. 
> (Wiley, New York, 1980).
>
> 3. B B. E. Conway, in <I>Modern Aspects of Electrochemistry,</I> 
> edited by J. O. M. Bockris and B. E. Conway (Butterworths, London, 
> 1964), p. 43.
>
>

Ah that invalidates most of the replies that you have so far had in this
thread. As everyone has noted, Using XSLT2 or perl or anything else with
string editing capabilities (personally I like emacs lisp) would be
better to convert text to XML.

But your input is already XML you presumably want &#x0123; to be
interpreted as a character reference and <I>...</I> to be interpreted as
an element.

If you use the XSLT2 unparsed-text() function then this will _not_ be
the interpretation: &#x0123; would just be parsed as 8 characters
" & # x 0 1 2 3 ;"
It would be possible to use regular expression search to find strings
that matched &#x[0-9a-fA-F]+; and then write a hex to decimal conversion
function and generate the unicode character of that number, but that
sounds like a long way round.

If your input is a well formed XML entity then just input it using
document() and treat it as an XML to XML transformation. If there is no
top level element, either add one explicitly or write a small wrapper
xml document taht has a single element and then includes your file as an
external entity.

The string handling of the text nodes would still be easier with XSLT2's
regex functions, but you should start with document() (or doc()) not
unparsed-text.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.