Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] Text markup for web forums, eg. [b]bold text[/b]

From: "Daniel Joshua" <daniel.joshua@------------>
To:
Date: 6/2/2004 2:30:00 AM
Using "translate(translate(value, '[', '<'), ']', '>')" was one of the
things I thought of. But even if I did the escaping, this does not check the
correctness of the "tags" or guarantee I get well formed / valid (X)HTML.


Scenario 1 (Good Input)
=======================
XML (input):

  <text>
    <value>Text may contain [b]bold text[/b], [i]italics[/i] or both
[b][i]bold and italics[/i][/b].</value>
  </text>

(X)HTML (desired output):

  <div class="text">Text may contain <b>bold text</b>, <i>italics</i> or
both <b><i>bold and italics</i></b>.</div>



Scenario 2 (Bad Input)
======================
XML (input):

  <text>
    <value>[b]blah blah [b][i]blah blah[/b][/i]</value>
  </text>

(X)HTML (desired output):

  <div class="text"><b>blah blah [b][i]blah blah</b>[/i]</div>

I would like to leave non-matching / badly-nested "tags" alone, so they will
be visible to users and alert them to fix the input (this is for a forum
after all).


Regards,
Daniel


-----Original Message-----
From: M. David Peterson [mailto:m.david@xxxxxxxxxx]
Sent: Tuesday, 01 June, 2004 5:40 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Text markup for web forums, eg. [b]bold text[/b]


In rethinking through this and then testing it it occured to me that this
solution creates some issues with output escaping.  Ive got to attend to
some other things this morning but will take a look at this again later.

Best regards,

<M:D/>

----- Original Message -----
From: "M. David Peterson" <m.david@xxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, June 01, 2004 2:47 AM
Subject: Re: [xsl] Text markup for web forums, eg. [b]bold text[/b]


> Sometimes the most obvious solutions are the ones that get overlooked.
> Although you would obviously have to process this further for tags like
> [QUOTE] and [email].  But once the conversion to XML has taken place thats
> obviously not an issue.
>
> Give me a sec to update the code and Ill repost a much more elegant
> solution.
>
> Thanks George!
>
> <M:D/>
> ----- Original Message -----
> From: "George Cristian Bina" <george@xxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Tuesday, June 01, 2004 2:36 AM
> Subject: Re: [xsl] Text markup for web forums, eg. [b]bold text[/b]
>
>
>> Hi,
>>
>> Just an idea, I do not know if that helps, but...
>> you can translate the [] in <> and after this you should have well formed
>> XML and process it as you like with another stylesheet:
>>
>> <text>
>> <value>Text may contain <b>bold text</b>, <i>italics</i> or both
>> <b><i>bold and italics</i></b>.</value>
>> </text>
>>
>>
>> <?xml version="1.0" encoding="UTF-8" ?>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> version="1.0">
>>     <xsl:output method="text"/>
>>     <xsl:template match="/">
>>        <xsl:text>&lt;processedValue&gt;</xsl:text>
>>        <xsl:value-of select="translate(text/value, '[]', '&lt;>')"/>
>>        <xsl:text>&lt;/processedValue&gt;</xsl:text>
>>     </xsl:template>
>> </xsl:stylesheet>
>>
>>
>> <processedValue>Text may contain <b>bold text</b>, <i>italics</i> or both
>> <b><i>bold and italics</i></b>.</processedValue>
>>
>>
>> Best Regards,
>>  George
>> -----------------------------------------------
>> George Cristian Bina
>> <oXygen/> XML Editor & XSLT Editor/Debugger
>> www.---.com
>>
>>
>> Daniel Joshua wrote:
>>> I was reading through this, gave me some ideas.
>>>
>>> Except that it does not handle nested "markup" like my input (below).
>>>
>>>
>>>>XML (input):
>>>>
>>>> <text>
>>>>   <value>Text may contain [b]bold text[/b], [i]italics[/i] or both
>>>>[b][i]bold and italics[/i][/b].</value>
>>>> </text>
>> >> [...]
>>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent