Re: Conflicting templates



patrik.nyman@xxxxxxxxxxxx wrote:
I have this templates to mark up hyphenation over line breaks:

I'll try to look at this in more detail later, but... Y'know, this is the sort of task that I would suggest handling in the redering engine, rather than at the XML level. The renderer is the level which knows where line breaks are going to have to be inserted, and is traditionally where hyphenation is done as a result. That's generally driven by a dictionary, though it could certainly take advantage of hints in the source.






<xsl:template match="reg[@type='hyp']">
<xsl:apply-templates select="@orig"/>
</xsl:template>

<xsl:template match="reg[@type='hyp']/@orig">
<xsl:call-template name="html-hyphens"/>
</xsl:template>

<xsl:template name="html-hyphens">
<xsl:param name="w" select="."/>
<xsl:variable name="car"
select="substring-before($w,'|')"/>
<xsl:variable name="cdr"
select="substring-after($w,'|')"/>
<xsl:choose>
<xsl:when test="$cdr">
<xsl:value-of select="concat($car,'-')"/>
<br/>
<xsl:call-template name="html-hyphens">
<xsl:with-param name="w" select="$cdr"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$w"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

I also have this simple template for italic text:

<xsl:template match ="it">
<i><xsl:apply-templates/></i>
</xsl:template>

This works fine if I write something like:

<it><reg type="hyp" orig="Hyphe|nated">Hyphenated</reg></it>

Now I can choose if I want to preserve linebreaks or not.
But as it happens, in some of the texts I'm working on,
sometimes ony part of the word is in italics (or formatted
some other way), like <it>Hyphe</it>nated, and since I
can't do

<reg type="hyp" orig="<it>Hyphe</it>|nated"><it>Hyphe</it>nated</
reg>

I must write something like:

<choice type="hyp">
<orig><it>Hyphe</it>|nated</orig>
<reg><it>Hyphe</it>nated</reg>
</choice>

So for this I added the following templates:

<xsl:template match="choice[@type='hyp']">
<xsl:apply-templates select="./orig"/>
</xsl:template>

<xsl:template match="choice[@type='hyp']/orig">
<xsl:call-template name="html-hyphens"/>
</xsl:template>

But the combination of the <it> and <choose> elements
are not working. Can anyone help me out?

Thanks a lot
/Patrik Nyman



--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
.



Relevant Pages

  • Re: Form Template problems
    ... The template I created is really basic; there are two text form fields ... in the name of the case, and it automatically puts it in italics. ... can't just highlight one word in a field, ... > into the Documents folder with an alias in the Apple Menu. ...
    (microsoft.public.mac.office.word)
  • Formatting problems - Word 2003
    ... I have built a template for a specific set of documents. ... changed, italics have been added where there were none, and outline numbering ...
    (microsoft.public.word.application.errors)
  • Re: Problems with generating an index
    ... bolded and the Index 1 level style is changed to italics. ... automatically" or updating from another file (a template)? ... This reply is posted in the Newsgroup; please post any follow question or reply ...
    (microsoft.public.word.docmanagement)