[xsl] translate and templates and converting to LyX

Subject: [xsl] translate and templates and converting to LyX
From: "Jeremy C. Reed" <reed@xxxxxxxxxxxxx>
Date: Sat, 18 Sep 2004 23:30:18 -0700 (PDT)

I am converting XML files (that are in GuideXML format) to LyX format.

My stylesheet is using code like:

<!-- Paragraph -->
<xsl:template match="p">
<xsl:param name="chid"/>
\begin_layout Standard
<xsl:with-param name="chid" select="$chid"/>

It uses this apply-templates so it can also do emphasis (italics) and
bold, etc.

My problem is that I need any newlines in these <p>paragraphs</p> to be
converted to spaces, because LyX is not like HTML and expects a real space
between words or they will get merged.

My work-around is:

<xsl:template match="text()">
<xsl:value-of select="translate(., '&#xA;&#xD;', '  ')" />

But the above (as far as I can tell) applies to all my data. Do you have
any suggestions on how I can get it to only apply to data within the
<p>...</p> tags?

I tried putting the translate() function in the <xsl:with-param
name="chid" select="translate($chid, '&#xA;&#xD;', ' '"/> statement, but
it didn't change anything.

I had a look at the FAQ page about templates, but didn't seem to see what
I am looking for. http://www.dpawson.co.uk/xsl/sect2/N7654.html

Also, I have some "pre" tags that I need to convert each newline in the
data to a newline followed by a literal string "\newline" (and that
followed by a newline). I can't try it yet because I need to figure out my
first issue above or I may end up converting all my data.

I need to be selective while still recursively working on any tags within.

By the way, does anyone have any stylesheets I can look at that are used
for converting to LyX? (I need to start looking closely to db2latex-xsl,
but it looks like way more than I need.)


 Jeremy C. Reed

 	  	 	 BSD News, BSD tutorials, BSD links

Current Thread