xsl-list
[Top] [All Lists]

Re: [xsl] Dynamically Converting text within an element to xml nodes within the output document

2009-12-28 12:59:41
Thanks that worked, did the following.

<xsl:sequence 
select="saxon:parse(replace($content,'\[(/?\w+)([^\]]*?)\]','&lt;$1&gt;'))"/>


On Mon, Dec 28, 2009 at 5:33 PM, Michael Kay <mike(_at_)saxonica(_dot_)com> 
wrote:
It's probably simplest to replace [] by <> (e.g. using translate()) to
create lexical XML, and then parse the resulting string into a node tree by
using an extension such as saxon:parse().

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

-----Original Message-----
From: Alex Muir [mailto:alex(_dot_)g(_dot_)muir(_at_)gmail(_dot_)com]
Sent: 28 December 2009 17:29
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Dynamically Converting text within an element
to xml nodes within the output document

Hi,

Given input such as the following within the "text" element
in a larger xml document currently being processed by an XSL file:

<text>
[ZZ] [XX] [YY] X [/YY] [YY] Y [/YY] [/XX] [/ZZ] </text>

Is it possible to dynamically replace the [ ]  with < > to
output the text as xml nodes in the output document?
<text>
<ZZ><XX><YY>X</YY><YY>Y</YY></XX></ZZ>
</text>

What is making this difficult for me is that the text input
could come in different structures with other psuedo tags for
example a  [[BB]] or some other that may not be expected and
so ideally it would be nice to convert the [[ to < and the ]]
to > with a find and replace however getting the XSLT script
to recognize this converted string as XML nodes I can't seem
to find a way to do.


Regards

--

Alex
https://sites.google.com/a/utg.edu.gm/alex

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





-- 

Alex
https://sites.google.com/a/utg.edu.gm/alex

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>