• 15 апреля стартует «Курс «SQL-injection Master» ©» от команды The Codeby

    За 3 месяца вы пройдете путь от начальных навыков работы с SQL-запросами к базам данных до продвинутых техник. Научитесь находить уязвимости связанные с базами данных, и внедрять произвольный SQL-код в уязвимые приложения.

    На последнюю неделю приходится экзамен, где нужно будет показать свои навыки, взломав ряд уязвимых учебных сайтов, и добыть флаги. Успешно сдавшие экзамен получат сертификат.

    Запись на курс до 25 апреля. Получить промодоступ ...

RTF-данные в web-таблицу

NetWood

Lotus Team
17.04.2008
545
93
BIT
8
Надо вывести блогобразно данные из нескольких доков в WEB табличку - новости типа :). Данные лежат в RTF поле с картинками и прочими потрохами. Стандартными средствами - это никак - понятно.
Сгенерить HTML таблу в поле на LS не проблема. Проблема срендить в нее RTF данные из нескольких доков.

Начал смотреть dominoblog.nsf из 7-го сервера. Круто написано, но выцепить в свой проект то что там наворочено - проще застрелицца.

Может у кого есть простой пример - шаблон базы с выводом RTF данных в WEB табличку?
Схемка для привлечения внимания:
table
RTF - doc1
RTF - doc2
...
RTF - docN
/table
 

NetWood

Lotus Team
17.04.2008
545
93
BIT
8
Покуда никто не помог, пришлось искать в своих архивах. Нашел интересную базулину RT2Web.nsf.
В ней есть рендер через DXL RTF поля в текстовое HTMLTransfer. Немного допилил ее, чтобы показывало вью с данными по моему сабджу.

Док Работа с базой:
Example 1:
Document 1 in the view is the originally authored document. That form has a QueryClose event that calls the agent (CleanHTML_LS) which gets the Richtext, gets the XSL out of the XSLProfile document rtxsl field and performs the transformation. The resulting transformation is stored in the HTMLTransform field on the original document.

Example 2:
If you are just looking for the XSL, go to the Actions menu and run the "Open XSL Profile doc" where the XSL is stored in a RichText field.

Недоделки:
- Не рендятся гиперобъекты с ссылками URL. Резалтом являются цветовой текст без ссылки
- Некорректно рендятся изображения с ссылками - гиперобъектами. Просто вставляется <img height="500px" width="375px" src="web/foto/" border="0"/> без имени файла, а должно быть <img height="500px" width="375px" src="web/foto/$FILE/9960.gif" border="0"/>. Надо править руками в поле, то бишь аттач в доке присутствует сренденный, но не вставленный в линк. Имеджи без ссылок - все ок.
- В поле HTMLTransform добавляется лишнее <?xml version="1.0" encoding="UTF-8"?>, которое надо удалять руками, иначе на WEB поле не отображается.
- В строчке <div xmlns:d="http://www.lotus.com/dxl" вот это xmlns:d="http://www.lotus.com/dxl" не нужно. Надо убрать также как и тут <style type="text/css" xmlns:d="http://www.lotus.com/dxl">
- Если вставить HTMLTransform на форму main | mainnotes, то агент по Sub Queryclose GetAgent("(CleanHTML_LS)") не отрабатывает ???
- Самое главное - при изменении содержимого в RTF поле, содержимое HTMLTransform не пересохраняется. Надо создавать док заново :welcome:
- Не работает на RTF данных с большим объемом.

Поскольку в java я совершенно не копенгаген, то требуется внести в базку некоторые правки. Кто поможет?
А так все замечательно работает. Видно аттачи, таблички, текст и стили во вьюхе на web.

Архив rar - допиленное. RT2Web_orig.zip - оригинал.
 

Вложения

  • RT2Web.part1.rar
    878,9 КБ · Просмотры: 170
  • RT2Web.part2.rar
    453,3 КБ · Просмотры: 168
  • RT2Web_orig.zip
    924,4 КБ · Просмотры: 161

lmike

нет, пердело совершенство
Lotus Team
27.08.2008
7 940
609
BIT
210
ежели в резалте присут. ошметки от доминошного нэйм-спэйса - возможно нужный (принудительно) его не указали в шаблоне... (пример корректной работы - в обработке ПДФ, в кот. я участвовал) дело в том, что наследуются ns от родительского тега
руками удалять - это слишком :welcome:
большой объем - может вызывать аут-оф-мем у джавы (надо увеличить максимум хипа в ини)
про пересохранение - не понял... ДХЛ работает в бэкэнде, со всеми вытек. последствиями

файлы не отображаюся - не угадан тег (в ДХЛ)
др. словами - надо править ХСЛТ
 

NetWood

Lotus Team
17.04.2008
545
93
BIT
8
файлы не отображаюся - не угадан тег
Править надо несомненно. Подойдут ли туда куски из проекта по PDFCreator?
про пересохранение - не понял...
Ну не обновляются и все. Меняешь контент - рендер прежний.
Cтранность с этим полем HTMLTransform - не отображается в списке полей. Уж его и так и сяк - не видно.

Еще обнаружил - некорректно табулированный текст отображается.
Вообще, конечно, в резалте такой ворох дублированных стилей и прочих окурков. Видно-то оно, видно, но как кишки начнешь смотреть - ужос :welcome:
 

lmike

нет, пердело совершенство
Lotus Team
27.08.2008
7 940
609
BIT
210
Подойдут ли туда куски из проекта по PDFCreator?
ХСЛ переменные, кот. вытаскивают названия файлов
остальное - мало (только принцип) тамже ФОП
хотя ФОП, на выходе, может выдавать ХТМЛ, но я не рассматривал вопрос имеджей (в ПДФ они встроены)

Добавлено:
Меняешь контент - рендер прежний.
а док пересохраняется, перед рендеренгом?
 

rinsk

Lotus Team
12.11.2009
1 151
125
BIT
3
Надо вывести блогобразно данные из нескольких доков в WEB табличку - новости типа :newconfus:. Данные лежат в RTF поле с картинками и прочими потрохами. Стандартными средствами - это никак - понятно.
Сгенерить HTML таблу в поле на LS не проблема. Проблема срендить в нее RTF данные из нескольких доков.

Была такая проблемка лет 5 назад...
Заплюкавшись с рендерингом - просто сформировал каждую строку из AJAX запроса на получение док-та. Конечно есть недостатки... один из них - то что у браузеров по умолчанию 2 потока максимум на запрос. Но на хорошем канале или для интранет - вполне так:)
На xPage эта проблема говорят решена:)
 

NetWood

Lotus Team
17.04.2008
545
93
BIT
8
1. для интранет - вполне так
2. На xPage эта проблема говорят решена
Интранет не сильно интересен, а вот про xPage надо уточнить. Действительно? Я им не пользуюсь. Но даже если так, из-за узкой задачи поднимать 8 и прочие потроха не очень хочется.
 

rinsk

Lotus Team
12.11.2009
1 151
125
BIT
3
Интранет не сильно интересен, а вот про xPage надо уточнить. Действительно? Я им не пользуюсь. Но даже если так, из-за узкой задачи поднимать 8 и прочие потроха не очень хочется.

Действительно.
Дело в том, что при узких возможностях ка бэ и задачи то широкие на ум нейдут:newconfus:
Например в xPage наверняка будут работать под веб секции в РТ поле - и тд...
 

lmike

нет, пердело совершенство
Lotus Team
27.08.2008
7 940
609
BIT
210
покручу код, в редкторе XSL посмотрю..., мобуть чего смогу сказать
 

lmike

нет, пердело совершенство
Lotus Team
27.08.2008
7 940
609
BIT
210
бегло просмотрел код...
очень смущает:
Код:
					RichTextItem rt = doc.createRichTextItem(filename);

rt.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "", fullfilepath, filename);
rt.setEncrypted(false);
rt.setProtected(false);
rt.setSigned(false);
rt.setSummary(false);
для каждой картинки
второе - приведение к типу РТайтема - зачем оно (RichTextItem rt = (RichTextItem) doc.getFirstItem("HTMLTransform"):), можно просто удалить айтэм, по имени

также - я не разобрался - зачем 2-а раза прогоняется трансформация:
// transform the rss feed to html
String newHTML = transformFeed((Source) xmlSource, xsltSource);
и
XSLProcessor xp = new XSLProcessor(new XML4JLiaison4dom());
StringReader xmlSource2 = new StringReader(newHTML);
StringReader xslSource2 = new StringReader(xslProfile.getItemValueString("RTXSL"));
StringWriter sw = new StringWriter();
XSLTInputSource xs = new XSLTInputSource(xmlSource2);
XSLTInputSource xt = new XSLTInputSource(xslSource2);
XSLTResultTarget tout = new XSLTResultTarget(sw);

xp.process(xs, xt, tout);
 

lmike

нет, пердело совершенство
Lotus Team
27.08.2008
7 940
609
BIT
210
в табле ХСЛТ д.б.:
Код:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:d="http://www.lotus.com/dxl" exclude-result-prefixes="d">
<xsl:output method="html"/>
....
это отменит вывод тега xml (и нэймспейс у div)

вот эта штука м.б. чёт и д.б. "резать", но в обработке ничего не написано (нет обработчика), потому оно просто копирует стрим
// transform the rss feed to html
String newHTML = transformFeed((Source) xmlSource, xsltSource);

прелестей принудительного указания XSLT процессора, я не заметил, можно стандартно:
<!--shcode--><pre><code class='java'>// XSLProcessor xp = new XSLProcessor(new XML4JLiaison4dom());
StringReader xmlSource2 = new StringReader(newHTML);
StringReader xslSource2 = new StringReader(xslProfile.getItemValueString("RTXSL"));
StringWriter sw = new StringWriter();

transformer = transFact.newTransformer(new StreamSource(xslSource2));
transformer.transform(new StreamSource(xmlSource2), new StreamResult(sw));

// XSLTInputSource xs = new XSLTInputSource(xmlSource2);
// XSLTInputSource xt = new XSLTInputSource(xslSource2);
// XSLTResultTarget tout = new XSLTResultTarget(sw);

// xp.process(xs, xt, tout);[/CODE]
 

NetWood

Lotus Team
17.04.2008
545
93
BIT
8
Ну а вот, собственно, и конверт RTF to HTML агентом на Lotus Script. Дешево и сердито. Нашел только один трабл - в картинки с линками добавляет лишние "" в href и не работает линк по картинке. А так без всяких DXL XSLT работает :ya_lamo: + Для начинающих на Web пойдет в самый раз: База содержит азы по веб навигации, всякие $$NavigatorTemplateDefault, $$ViewTemplateDefault, подключение стилей, необходимые CGI поля и прочее...

В базе вьюха с выводом полей HTMLBody. На странице дока можно посмотреть поле HTMLBody и оригинал из RTF - найдите 2 отличия :KillMe:
Проще сделан вывод имеджей. Если в базе "выше" они аттачились в док, то тут просто линкуются ссылки на Body типа 0/4B1EE75FB3C2310CC3257574005CF952/Body/M2?OpenElement

... Подправил немного базку- был глюк с линками href
t=Split(tmp,"<a href=") на t=Split(tmp,"<a href='")
 

Вложения

  • notesrichtext_to_html.zip
    760 КБ · Просмотры: 193

NetWood

Lotus Team
17.04.2008
545
93
BIT
8
Остапа понесло :KillMe:
Ревижон ту:
- док содержащий имеджи из RTF сделан ответом на основной.
- сохранена настройка <table border width=100%> в <table width=100%>. Таблы в нотес по полю будут 100%, соответственно фиксированные - фиксированными, а внутри TD все само собой по %
tmp=Replace(tmp, |<td width=|, |<td style=width:|)
- не сплитятся TD по умолчанию, а зачем?
mText=htmlTidy(mText,1,1,0) ''htmlTidy (Byval html As String, SplitTable As Integer, SplitTr As Integer, SplitTd As Integer )
- в специальных тегах <$HTML>text</$HTML> можно писать простейший HTML. Теги <$HTML></$HTML>заменяются потом на комменты.
Важно! Код должен быть без пробелов, иначе будут окурки в виде  [&nbsp]
Код:
Function InnerHTML (Byval html As String ) As String
''преобразует значения с амперсандами внутри тегов <$HTML>text</$HTML> в НTML
Dim crlf As String, tmp As String, i As Long, tmpx As Variant, tmpa As Variant
Dim x As Integer,y As Integer,z As Integer
Dim t As Variant, u As Long, r As String

'' все амперсанды внутри <$HTML> заменить на теги	
tmp=Replace(html, "<$HTML>", "<$HTML>")
tmp=Replace(tmp, "</$HTML>", "</$HTML>")
x=Instr(1,tmp,"<$HTML>")
While x<>0 
tmpx=Mid$(tmp,x,Instr(x,tmp,"</$HTML>")-x) 
tmpa=Replace(tmpx, "<", "<")
tmpa=Replace(tmpa, ">", ">")
tmpa=Replace(tmpa, """, "'")	
'	tmpa=Replace(tmpa, "  ", "'")	''не удалось посечь   в <script - оставляет лишние '
'	tmpa=Replace(tmpa, "<br />", "'")	
tmp=Replace(tmp, tmpx, tmpa)	
tmp=Replace(tmp, "<$HTML>", "<!-$HTML->")	
x = Instr(1,tmp,"<$HTML>")
Wend	
tmp=Replace(tmp, "</$HTML>", "<!-/$HTML->")

InnerHTML = tmp
End Function
 

Вложения

  • notesrichtext_to_html2.zip
    567 КБ · Просмотры: 315

lmike

нет, пердело совершенство
Lotus Team
27.08.2008
7 940
609
BIT
210
подправил, но не перезагружал в базу, такчта брать мона отсюдова :) (это к тому, что линки не работают, на тексте)
<div class="sp-wrap"><div class="sp-head-wrap"><div class="sp-head folded clickable">"XSL, в кот. есть код для href"</div></div><div class="sp-body"><div class="sp-content">
Код:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:d="http://www.lotus.com/dxl" exclude-result-prefixes="d">
<xsl:output method="html"/>
<xsl:variable name="uid">
<xsl:value-of select="//d:document/d:noteinfo/@unid"/>
</xsl:variable>
<xsl:variable name="pname">
<xsl:value-of select="//d:document/d:item[@name='DocPage']"/>
</xsl:variable>
<xsl:variable name="viewname">
<xsl:value-of select="//d:document/d:item[@name='DocView']"/>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="//d:document"/>
</xsl:template>
<xsl:template match="d:document">
<xsl:apply-templates select="d:item"/>
</xsl:template>
<xsl:template match="d:item">
<xsl:apply-templates select="d:richtext"/>
</xsl:template>
<xsl:template match="d:richtext">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="d:table">
<table width="100%" cellspacing="0" cellpadding="0">
<xsl:attribute name="width">
<xsl:if test="@widthtype='fitmargins'">100%</xsl:if>
</xsl:attribute>
<xsl:attribute name="style">border-collapse: collapse;<xsl:if
test="string(d:border/@style)"> border-style: <xsl:choose>
<xsl:when test="d:border/@style='dot'">dotted</xsl:when>
<xsl:when test="d:border/@style='dash'">dashed</xsl:when>
<xsl:otherwise>
<xsl:value-of select="d:border/@style"/>
</xsl:otherwise>
</xsl:choose>;</xsl:if><xsl:if test="string(d:border/@width)"> border-width:
<xsl:value-of select="d:border/@width"/>;</xsl:if><xsl:if
test="string(d:border/@color)"> border-color: <xsl:value-of
select="d:border/@color"/>;</xsl:if></xsl:attribute>
<tr>
<xsl:for-each select="d:tablecolumn">
<!--This sets the column widths-->
<th style="border: 0px 0px 0px 0px;">
<xsl:attribute name="width">
<xsl:choose>
<xsl:when test="contains(@width, 'in')">
<xsl:variable name="wd">
<xsl:value-of select="substring-before(@width, 'in')"/>
</xsl:variable>
<xsl:value-of select="70*$wd"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@width"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</th>
</xsl:for-each>
</tr>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="d:tablerow">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="d:tablecell">
<td valign="top">
<xsl:attribute name="style">border-width: <xsl:choose>
<xsl:when test="string(@borderwidth)">
<xsl:value-of select="@borderwidth"/>
</xsl:when>
<xsl:otherwise>1px</xsl:otherwise>
</xsl:choose>; border-color: <xsl:choose>
<xsl:when test="string(../../@cellbordercolor)">
<xsl:value-of select="../../@cellbordercolor"/>
</xsl:when>
<xsl:otherwise>black</xsl:otherwise>
</xsl:choose>; border-style: solid;<xsl:choose>
<xsl:when test="string(@bgcolor)"> background-color: <xsl:value-of
select="@bgcolor"/>;</xsl:when>
</xsl:choose></xsl:attribute>
<xsl:apply-templates/>
</td>
</xsl:template>
<xsl:template match="d:pardef">
<xsl:comment> ****************** paragraph definition ****************** </xsl:comment>
<style>
.par_<xsl:value-of select="$uid"/>
_<xsl:value-of select="@id"/>
{<xsl:if test="@align!=''">text-align: <xsl:value-of select="@align"/>;</xsl:if>
font-family: sans-serif;
color: black;
font-size: 10pt;
font-weight: normal;
text-decoration: none;
}</style>
</xsl:template>
<xsl:template match="d:par">
<xsl:variable name="defnum">
<xsl:value-of select="@def"/>
</xsl:variable>
<xsl:choose>
<xsl:when
test="contains(//d:document/d:item/d:richtext/d:pardef[@id=$defnum]/@list, 'bullet') or contains(//d:document/d:item/d:richtext/d:table/d:tablerow/d:tablecell/d:pardef[@id=$defnum]/@list, 'bullet')">
<xsl:if test="preceding-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[<ul>]]></xsl:text>
</xsl:if>
<li>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of
select="@def"/></xsl:attribute>
<xsl:apply-templates/>
</li>
<xsl:if test="following-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[</ul>]]></xsl:text>
</xsl:if>
</xsl:when>
<xsl:when
test="contains(//d:document/d:item/d:richtext/d:pardef[@id=$defnum]/@list, 'number') or contains(//d:document/d:item/d:richtext/d:table/d:tablerow/d:tablecell/d:pardef[@id=$defnum]/@list, 'number')">
<xsl:if test="preceding-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[<ol>]]></xsl:text>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of
select="@def"/></xsl:attribute>
</xsl:if>
<li>
<xsl:attribute name="style">font-family: <xsl:value-of
select="d:run/d:font/@name"/>; font-size: <xsl:value-of
select="d:run/d:font/@size"/>;<xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'bold')"> font-weight:
bold;</xsl:when>
<xsl:otherwise> font-weight: normal;</xsl:otherwise>
</xsl:choose><xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'italic')"> font-style:
italic;</xsl:when>
<xsl:otherwise> font-style: normal;</xsl:otherwise>
</xsl:choose><!--Can't have both selected at same time--><xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'superscript')">
vertical-align: super;</xsl:when>
<xsl:when test="contains(d:run/d:font/@style, 'subscript')">
vertical-align: sub;</xsl:when>
<xsl:otherwise> vertical-align: bottom;</xsl:otherwise>
</xsl:choose><!--Could potentially have both selected here-->
text-decoration: <xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'underline')">underline </xsl:when>
<xsl:when test="contains(d:run/d:font/@style, 'strikethrough')"
>line-through</xsl:when>
<xsl:otherwise>none</xsl:otherwise>
</xsl:choose>; color: <xsl:choose>
<xsl:when test="string(d:run/d:font/@color)">
<xsl:value-of select="d:run/d:font/@color"/>
</xsl:when>
<xsl:otherwise>black</xsl:otherwise>
</xsl:choose>;</xsl:attribute>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of
select="@def"/></xsl:attribute>
<xsl:apply-templates/>
</li>
<xsl:if test="following-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[</ol>]]></xsl:text>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<div>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of
select="@def"/></xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="d:urllink">
<xsl:comment> ****************** urllink definition ****************** </xsl:comment>
<a>
<xsl:attribute name="href">
<xsl:value-of select="@href"/>
</xsl:attribute>
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="d:run">
<span>
<xsl:attribute name="style">font-family: <xsl:value-of select="d:font/@name"/>;
font-size: <xsl:value-of select="d:font/@size"/>;<xsl:choose>
<xsl:when test="contains(d:font/@style, 'bold')"> font-weight: bold;</xsl:when>
<xsl:otherwise> font-weight: normal;</xsl:otherwise>
</xsl:choose><xsl:choose>
<xsl:when test="contains(d:font/@style, 'italic')"> font-style:
italic;</xsl:when>
<xsl:otherwise> font-style: normal;</xsl:otherwise>
</xsl:choose><!--Can't have both selected at same time--><xsl:choose>
<xsl:when test="contains(d:font/@style, 'superscript')"> vertical-align:
super;</xsl:when>
<xsl:when test="contains(d:font/@style, 'subscript')"> vertical-align:
sub;</xsl:when>
<xsl:otherwise> vertical-align: bottom;</xsl:otherwise>
</xsl:choose><!--Could potentially have both selected here--> text-decoration: <xsl:choose>
<xsl:when test="contains(d:font/@style, 'underline')">underline </xsl:when>
<xsl:when test="contains(d:font/@style, 'strikethrough')"
>line-through</xsl:when>
<xsl:otherwise>none</xsl:otherwise>
</xsl:choose>; color: <xsl:choose>
<xsl:when test="string(d:font/@color)">
<xsl:value-of select="d:font/@color"/>
</xsl:when>
<xsl:otherwise>black</xsl:otherwise>
</xsl:choose>;</xsl:attribute>
<xsl:apply-templates/>  </span>
</xsl:template>
<xsl:template match="d:attachmentref">
<a target="8">
<xsl:attribute name="href"><xsl:value-of select="$viewname"/>/<xsl:value-of
select="$pname"/>/$FILE/<xsl:value-of select="@name"/></xsl:attribute>
<img>
<xsl:attribute name="height">
<xsl:value-of select="d:picture/@height"/>
</xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="d:picture/@width"/>
</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="$viewname"/>/<xsl:value-of
select="$pname"/>/$FILE/<xsl:value-of select="d:picture/d:gif"
/></xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
</img>
</a>
</xsl:template>
<xsl:template match="d:picture">
<xsl:comment> ****************** picture definition ****************** </xsl:comment>
<img>
<xsl:attribute name="height">
<xsl:value-of select="@height"/>
</xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="@width"/>
</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="$viewname"/>/<xsl:value-of
select="$pname"/>/$FILE/<xsl:value-of select="d:gif"/></xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
</img>
</xsl:template>

</xsl:stylesheet>
 

lmike

нет, пердело совершенство
Lotus Team
27.08.2008
7 940
609
BIT
210
добавил обработку стартовых пробелов, в предложениях (меняем на неразрывные пробелы)
важно для ХТМЛ (иначе не будет отступов, сделаных так)
над табуляцией думаю (можно её эмулировать как несколько  )
подчистил (местами) шаблон
<div class="sp-wrap"><div class="sp-head-wrap"><div class="sp-head folded clickable">"XSLT"</div></div><div class="sp-body"><div class="sp-content">
Код:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:d="http://www.lotus.com/dxl" exclude-result-prefixes="d">
<xsl:output method="html" indent="yes"/>
<!-- <xsl:strip-space elements="*"/> -->
<xsl:preserve-space elements="par"/>
<xsl:variable name="uid">
<xsl:value-of select="//d:document/d:noteinfo/@unid"/>
</xsl:variable>
<xsl:variable name="pname">
<xsl:value-of select="//d:document/d:item[@name='DocPage']"/>
</xsl:variable>
<xsl:variable name="viewname">
<xsl:value-of select="//d:document/d:item[@name='DocView']"/>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="//d:document"/>
</xsl:template>
<xsl:template match="d:document">
<xsl:apply-templates select="d:item"/>
</xsl:template>
<xsl:template match="d:item">
<xsl:apply-templates select="d:richtext"/>
</xsl:template>
<xsl:template match="d:richtext">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="d:table">
<table width="100%" cellspacing="0" cellpadding="0">
<xsl:attribute name="width">
<xsl:if test="@widthtype='fitmargins'">100%</xsl:if>
</xsl:attribute>
<xsl:attribute name="style">border-collapse: collapse;<xsl:if
test="string(d:border/@style)"> border-style: <xsl:choose>
<xsl:when test="d:border/@style='dot'">dotted</xsl:when>
<xsl:when test="d:border/@style='dash'">dashed</xsl:when>
<xsl:otherwise>
<xsl:value-of select="d:border/@style"/>
</xsl:otherwise>
</xsl:choose>; </xsl:if>
<xsl:if test="string(d:border/@width)"> border-width: <xsl:value-of select="d:border/@width"/>; <xsl:text/></xsl:if>
<xsl:if test="string(d:border/@color)"> border-color: <xsl:value-of select="d:border/@color"/>; <xsl:text/></xsl:if>
</xsl:attribute>
<tr>
<xsl:for-each select="d:tablecolumn">
<!--This sets the column widths-->
<th style="border: 0px 0px 0px 0px;">
<xsl:attribute name="width">
<xsl:choose>
<xsl:when test="contains(@width, 'in')">
<xsl:variable name="wd">
<xsl:value-of select="substring-before(@width, 'in')"/>
</xsl:variable>
<xsl:value-of select="72*$wd"/><xsl:text>px</xsl:text></xsl:when>
<xsl:otherwise><xsl:value-of select="@width"/><xsl:text>px</xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:attribute></th><xsl:text/>
</xsl:for-each>
</tr>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="d:tablerow">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="d:tablecell">
<td valign="top">
<xsl:attribute name="style">border-width: <xsl:choose>
<xsl:when test="string(@borderwidth)">
<xsl:value-of select="@borderwidth"/>
</xsl:when>
<xsl:otherwise>1px <xsl:text/></xsl:otherwise>
</xsl:choose>; border-color: <xsl:text/>
<xsl:choose>
<xsl:when test="string(../../@cellbordercolor)">
<xsl:value-of select="../../@cellbordercolor"/>
</xsl:when>
<xsl:otherwise>black</xsl:otherwise>
</xsl:choose>; border-style: solid; <xsl:text/>
<xsl:choose>
<xsl:when test="string(@bgcolor)"> background-color: <xsl:value-of select="@bgcolor"/>; <xsl:text/>
</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates/>
</td>
</xsl:template>
<xsl:template match="d:pardef">
<xsl:comment> ****************** paragraph definition ****************** </xsl:comment>
<style>
.par_<xsl:value-of select="$uid"/>
_<xsl:value-of select="@id"/>
{<xsl:if test="@align!=''">text-align: <xsl:value-of select="@align"/>;</xsl:if>
font-family: sans-serif;
color: black;
font-size: 10pt;
font-weight: normal;
text-decoration: none;
}
</style>
</xsl:template>
<xsl:template match="text()">
<xsl:comment> ****************** text match ****************** </xsl:comment>
<xsl:variable name="txt" select="."/>
<xsl:choose>
<xsl:when test="starts-with($txt,' ')">
<xsl:variable name="norm" select="normalize-space($txt)"/>
<xsl:variable name="space">
<xsl:choose>
<xsl:when test="contains($norm,' ')">
<xsl:value-of select="substring-before($txt,substring-before($norm,' '))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-before($txt,$norm)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="replacement"><xsl:text> </xsl:text></xsl:variable>
<xsl:value-of select="translate($space, ' 
', $replacement)"/>
<xsl:value-of select="substring-after($txt,$space)"/>
<!-- <xsl:value-of select="$txt"/> -->
</xsl:when>
<xsl:otherwise><xsl:value-of select="$txt"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="d:par">
<xsl:variable name="defnum">
<xsl:value-of select="@def"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains(//d:document/d:item/d:richtext/d:pardef[@id=$defnum]/@list, 'bullet') or 
contains(//d:document/d:item/d:richtext/d:table/d:tablerow/d:tablecell/d:pardef[@id=$defnum]/@list, 'bullet')">
<xsl:if test="preceding-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[<ul>]]></xsl:text>
</xsl:if>
<li>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of select="@def"/></xsl:attribute>
<xsl:apply-templates/>
</li>
<xsl:if test="following-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[</ul>]]></xsl:text>
</xsl:if>
</xsl:when>
<xsl:when test="contains(//d:document/d:item/d:richtext/d:pardef[@id=$defnum]/@list, 'number') or contains(//d:document/d:item/d:richtext/d:table/d:tablerow/d:tablecell/d:pardef[@id=$defnum]/@list, 'number')">
<xsl:if test="preceding-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[<ol>]]></xsl:text>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of select="@def"/></xsl:attribute>
</xsl:if>
<li>
<xsl:attribute name="style"> <xsl:text/>
font-family: <xsl:value-of select="d:run/d:font/@name"/>; font-size: <xsl:value-of select="d:run/d:font/@size"/>; <xsl:text/>
<xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'bold')">font-weight: bold;<xsl:text/></xsl:when>
<xsl:otherwise>font-weight: normal;<xsl:text/></xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'italic')"> <xsl:text/>font-style: italic;<xsl:text/></xsl:when>
<xsl:otherwise>font-style: normal;<xsl:text/></xsl:otherwise>
</xsl:choose>
<!--Can't have both selected at same time-->
<xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'superscript')">vertical-align: super;<xsl:text/></xsl:when>
<xsl:when test="contains(d:run/d:font/@style, 'subscript')">vertical-align: sub;<xsl:text/></xsl:when>
<xsl:otherwise>vertical-align: bottom;<xsl:text/></xsl:otherwise>
</xsl:choose><!--Could potentially have both selected here-->text-decoration: <xsl:text/>
<xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'underline')">underline <xsl:text/></xsl:when>
<xsl:when test="contains(d:run/d:font/@style, 'strikethrough')">line-through <xsl:text/></xsl:when>
<xsl:otherwise>none<xsl:text/></xsl:otherwise>
</xsl:choose>; color: <xsl:text/>
<xsl:choose>
<xsl:when test="string(d:run/d:font/@color)">
<xsl:value-of select="d:run/d:font/@color"/>
</xsl:when>
<xsl:otherwise>black<xsl:text/></xsl:otherwise>
</xsl:choose>;<xsl:text/>
</xsl:attribute>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of select="@def"/></xsl:attribute>
<xsl:apply-templates/>
</li>
<xsl:if test="following-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[</ol>]]></xsl:text>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<div>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of select="@def"/></xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="d:urllink">
<xsl:comment> ****************** urllink definition ****************** </xsl:comment>
<a>
<xsl:attribute name="href">
<xsl:value-of select="@href"/>
</xsl:attribute>
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="d:run">
<span>
<xsl:attribute name="style">font-family: <xsl:text/>
<xsl:value-of select="d:font/@name"/>; font-size: <xsl:text/>
<xsl:value-of select="d:font/@size"/>;<xsl:text/>
<xsl:choose>
<xsl:when test="contains(d:font/@style, 'bold')">font-weight: bold;</xsl:when>
<xsl:otherwise>font-weight: normal;</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="contains(d:font/@style, 'italic')"> font-style: italic;</xsl:when>
<xsl:otherwise>font-style: normal;</xsl:otherwise>
</xsl:choose>
<!--Can't have both selected at same time-->
<xsl:choose>
<xsl:when test="contains(d:font/@style, 'superscript')">vertical-align: super; </xsl:when>
<xsl:when test="contains(d:font/@style, 'subscript')">vertical-align: sub; </xsl:when>
<xsl:otherwise>vertical-align: bottom; </xsl:otherwise>
</xsl:choose><!--Could potentially have both selected here-->text-decoration: <xsl:choose>
<xsl:when test="contains(d:font/@style, 'underline')">underline </xsl:when>
<xsl:when test="contains(d:font/@style, 'strikethrough')">line-through</xsl:when>
<xsl:otherwise>none</xsl:otherwise>
</xsl:choose>; color: <xsl:choose>
<xsl:when test="string(d:font/@color)">
<xsl:value-of select="d:font/@color"/>
</xsl:when>
<xsl:otherwise>black</xsl:otherwise>
</xsl:choose>;</xsl:attribute>
<xsl:apply-templates/>  </span>
</xsl:template>
<xsl:template match="d:attachmentref">
<a target="8">
<xsl:attribute name="href"><xsl:value-of select="$viewname"/>/<xsl:value-of
select="$pname"/>/$FILE/<xsl:value-of select="@name"/></xsl:attribute>
<img>
<xsl:attribute name="height">
<xsl:value-of select="d:picture/@height"/>
</xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="d:picture/@width"/>
</xsl:attribute>
<xsl:attribute name="src">
<xsl:value-of select="$viewname"/>/<xsl:value-of select="$pname"/>/$FILE/<xsl:value-of select="d:picture/d:gif"/>
</xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
</img>
</a>
</xsl:template>
<xsl:template match="d:picture">
<xsl:comment> ****************** picture definition ****************** </xsl:comment>
<img>
<xsl:attribute name="height">
<xsl:value-of select="@height"/>
</xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="@width"/>
</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="$viewname"/>/<xsl:value-of
select="$pname"/>/$FILE/<xsl:value-of select="d:gif"/></xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
</img>
</xsl:template>

</xsl:stylesheet>
 

lmike

нет, пердело совершенство
Lotus Team
27.08.2008
7 940
609
BIT
210
сделал ф-цию обработки символов табуляции (кто не знал - символы ) реплэйсю их на 'ŠŠŠ '
что соответ. 3-м nbsp (неразрывный пробел) + " " - шобы перенос по строкам (после таба) работал
фактически длина табуляции 4-е символа
<div class="sp-wrap"><div class="sp-head-wrap"><div class="sp-head folded clickable">"традиционно - XSLT"</div></div><div class="sp-body"><div class="sp-content">
Код:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:d="http://www.lotus.com/dxl" exclude-result-prefixes="d">
<xsl:output method="html" indent="yes"/>
<!-- <xsl:strip-space elements="*"/> -->
<xsl:preserve-space elements="par"/>
<xsl:variable name="uid">
<xsl:value-of select="//d:document/d:noteinfo/@unid"/>
</xsl:variable>
<xsl:variable name="pname">
<xsl:value-of select="//d:document/d:item[@name='DocPage']"/>
</xsl:variable>
<xsl:variable name="viewname">
<xsl:value-of select="//d:document/d:item[@name='DocView']"/>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="//d:document"/>
</xsl:template>
<xsl:template match="d:document">
<xsl:apply-templates select="d:item"/>
</xsl:template>
<xsl:template match="d:item">
<xsl:apply-templates select="d:richtext"/>
</xsl:template>
<xsl:template match="d:richtext">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="d:table">
<table width="100%" cellspacing="0" cellpadding="0">
<xsl:attribute name="width">
<xsl:if test="@widthtype='fitmargins'">100%</xsl:if>
</xsl:attribute>
<xsl:attribute name="style">border-collapse: collapse;<xsl:if
test="string(d:border/@style)"> border-style: <xsl:choose>
<xsl:when test="d:border/@style='dot'">dotted</xsl:when>
<xsl:when test="d:border/@style='dash'">dashed</xsl:when>
<xsl:otherwise>
<xsl:value-of select="d:border/@style"/>
</xsl:otherwise>
</xsl:choose>; </xsl:if>
<xsl:if test="string(d:border/@width)"> border-width: <xsl:value-of select="d:border/@width"/>; <xsl:text/></xsl:if>
<xsl:if test="string(d:border/@color)"> border-color: <xsl:value-of select="d:border/@color"/>; <xsl:text/></xsl:if>
</xsl:attribute>
<tr>
<xsl:for-each select="d:tablecolumn">
<!--This sets the column widths-->
<th style="border: 0px 0px 0px 0px;">
<xsl:attribute name="width">
<xsl:choose>
<xsl:when test="contains(@width, 'in')">
<xsl:variable name="wd">
<xsl:value-of select="substring-before(@width, 'in')"/>
</xsl:variable>
<xsl:value-of select="72*$wd"/><xsl:text>px</xsl:text></xsl:when>
<xsl:otherwise><xsl:value-of select="@width"/><xsl:text>px</xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:attribute></th><xsl:text/>
</xsl:for-each>
</tr>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="d:tablerow">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="d:tablecell">
<td valign="top">
<xsl:attribute name="style">border-width: <xsl:choose>
<xsl:when test="string(@borderwidth)">
<xsl:value-of select="@borderwidth"/>
</xsl:when>
<xsl:otherwise>1px <xsl:text/></xsl:otherwise>
</xsl:choose>; border-color: <xsl:text/>
<xsl:choose>
<xsl:when test="string(../../@cellbordercolor)">
<xsl:value-of select="../../@cellbordercolor"/>
</xsl:when>
<xsl:otherwise>black</xsl:otherwise>
</xsl:choose>; border-style: solid; <xsl:text/>
<xsl:choose>
<xsl:when test="string(@bgcolor)"> background-color: <xsl:value-of select="@bgcolor"/>; <xsl:text/>
</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates/>
</td>
</xsl:template>
<xsl:template match="d:pardef">
<xsl:comment> ****************** paragraph definition ****************** </xsl:comment>
<style>
.par_<xsl:value-of select="$uid"/>
_<xsl:value-of select="@id"/>
{<xsl:if test="@align!=''">text-align: <xsl:value-of select="@align"/>;</xsl:if>
font-family: sans-serif;
color: black;
font-size: 10pt;
font-weight: normal;
text-decoration: none;
}
</style>
</xsl:template>
<!--tabreplace function-->
<xsl:template name="tabreplace">
<xsl:param name="str" select="."/>
<xsl:param name="search-for" select="'	'"/>
<xsl:param name="replace-with">    </xsl:param>
<xsl:choose>
<xsl:when test="contains($str, $search-for)">
<xsl:value-of select="substring-before($str, $search-for)"/>
<xsl:copy-of select="$replace-with"/>
<xsl:call-template name="tabreplace">
<xsl:with-param name="str"
select="substring-after($str, $search-for)"/>
<xsl:with-param name="search-for" select="$search-for"/>
<xsl:with-param name="replace-with" select="$replace-with"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$str"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text()">
<xsl:comment> ****************** text match ****************** </xsl:comment>
<xsl:variable name="txt" select="."/>
<xsl:choose>
<xsl:when test="starts-with($txt,' ')">
<xsl:variable name="norm" select="normalize-space($txt)"/>
<xsl:variable name="space">
<xsl:choose>
<xsl:when test="contains($norm,' ')">
<xsl:value-of select="substring-before($txt,substring-before($norm,' '))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-before($txt,$norm)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="replacement"><xsl:text> </xsl:text></xsl:variable>
<xsl:call-template name="tabreplace">
<xsl:with-param name="str">
<xsl:value-of select="translate($space, ' 
', $replacement)"/>
<xsl:value-of select="substring-after($txt,$space)"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- <xsl:value-of select="$txt"/> -->
<xsl:call-template name="tabreplace"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="d:par">
<xsl:variable name="defnum">
<xsl:value-of select="@def"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains(//d:document/d:item/d:richtext/d:pardef[@id=$defnum]/@list, 'bullet') or 
contains(//d:document/d:item/d:richtext/d:table/d:tablerow/d:tablecell/d:pardef[@id=$defnum]/@list, 'bullet')">
<xsl:if test="preceding-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[<ul>]]></xsl:text>
</xsl:if>
<li>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of select="@def"/></xsl:attribute>
<xsl:apply-templates/>
</li>
<xsl:if test="following-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[</ul>]]></xsl:text>
</xsl:if>
</xsl:when>
<xsl:when test="contains(//d:document/d:item/d:richtext/d:pardef[@id=$defnum]/@list, 'number') or contains(//d:document/d:item/d:richtext/d:table/d:tablerow/d:tablecell/d:pardef[@id=$defnum]/@list, 'number')">
<xsl:if test="preceding-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[<ol>]]></xsl:text>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of select="@def"/></xsl:attribute>
</xsl:if>
<li>
<xsl:attribute name="style">font-family: <xsl:text/>
<xsl:value-of select="d:run/d:font/@name"/>; font-size: <xsl:value-of select="d:run/d:font/@size"/>; <xsl:text/>
<xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'bold')">font-weight: bold;</xsl:when>
<xsl:otherwise>font-weight: normal;</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'italic')"> <xsl:text/>font-style: italic;</xsl:when>
<xsl:otherwise>font-style: normal;</xsl:otherwise>
</xsl:choose>
<!--Can't have both selected at same time-->
<xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'superscript')">vertical-align: super;<xsl:text/></xsl:when>
<xsl:when test="contains(d:run/d:font/@style, 'subscript')">vertical-align: sub;<xsl:text/></xsl:when>
<xsl:otherwise>vertical-align: bottom;<xsl:text/></xsl:otherwise>
</xsl:choose><!--Could potentially have both selected here-->text-decoration: <xsl:text/>
<xsl:choose>
<xsl:when test="contains(d:run/d:font/@style, 'underline')">underline <xsl:text/></xsl:when>
<xsl:when test="contains(d:run/d:font/@style, 'strikethrough')">line-through <xsl:text/></xsl:when>
<xsl:otherwise>none<xsl:text/></xsl:otherwise>
</xsl:choose>; color: <xsl:text/>
<xsl:choose>
<xsl:when test="string(d:run/d:font/@color)">
<xsl:value-of select="d:run/d:font/@color"/>
</xsl:when>
<xsl:otherwise>black<xsl:text/></xsl:otherwise>
</xsl:choose>;<xsl:text/>
</xsl:attribute>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of select="@def"/></xsl:attribute>
<xsl:apply-templates/>
</li>
<xsl:if test="following-sibling::d:par[1]/@def!=$defnum">
<xsl:text disable-output-escaping="yes"><![CDATA[</ol>]]></xsl:text>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<div>
<xsl:attribute name="class">par_<xsl:value-of select="$uid"/>_<xsl:value-of select="@def"/></xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="d:urllink">
<xsl:comment> ****************** urllink definition ****************** </xsl:comment>
<a>
<xsl:attribute name="href">
<xsl:value-of select="@href"/>
</xsl:attribute>
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="d:run">
<span>
<xsl:attribute name="style">font-family: <xsl:text/>
<xsl:value-of select="d:font/@name"/>; font-size: <xsl:text/>
<xsl:value-of select="d:font/@size"/>;<xsl:text/>
<xsl:choose>
<xsl:when test="contains(d:font/@style, 'bold')">font-weight:bold;</xsl:when>
<xsl:otherwise>font-weight:normal;</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="contains(d:font/@style, 'italic')"> font-style:italic;</xsl:when>
<xsl:otherwise>font-style:normal;</xsl:otherwise>
</xsl:choose>
<!--Can't have both selected at same time-->
<xsl:choose>
<xsl:when test="contains(d:font/@style, 'superscript')">vertical-align: super; </xsl:when>
<xsl:when test="contains(d:font/@style, 'subscript')">vertical-align: sub; </xsl:when>
<xsl:otherwise>vertical-align: bottom; </xsl:otherwise>
</xsl:choose><!--Could potentially have both selected here-->text-decoration: <xsl:choose>
<xsl:when test="contains(d:font/@style, 'underline')">underline </xsl:when>
<xsl:when test="contains(d:font/@style, 'strikethrough')">line-through</xsl:when>
<xsl:otherwise>none</xsl:otherwise>
</xsl:choose>; color: <xsl:choose>
<xsl:when test="string(d:font/@color)">
<xsl:value-of select="d:font/@color"/>
</xsl:when>
<xsl:otherwise>black</xsl:otherwise>
</xsl:choose>;</xsl:attribute>
<xsl:apply-templates/>  </span>
</xsl:template>
<xsl:template match="d:attachmentref">
<a target="8">
<xsl:attribute name="href"><xsl:value-of select="$viewname"/>/<xsl:value-of
select="$pname"/>/$FILE/<xsl:value-of select="@name"/></xsl:attribute>
<img>
<xsl:attribute name="height">
<xsl:value-of select="d:picture/@height"/>
</xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="d:picture/@width"/>
</xsl:attribute>
<xsl:attribute name="src">
<xsl:value-of select="$viewname"/>/<xsl:value-of select="$pname"/>/$FILE/<xsl:value-of select="d:picture/d:gif"/>
</xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
</img>
</a>
</xsl:template>
<xsl:template match="d:picture">
<xsl:comment> ****************** picture definition ****************** </xsl:comment>
<img>
<xsl:attribute name="height">
<xsl:value-of select="@height"/>
</xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="@width"/>
</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="$viewname"/>/<xsl:value-of
select="$pname"/>/$FILE/<xsl:value-of select="d:gif"/></xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
</img>
</xsl:template>

</xsl:stylesheet>
 

lmike

нет, пердело совершенство
Lotus Team
27.08.2008
7 940
609
BIT
210
в планах - сделать xslt для FOP, но там - джава, безальтернативно (чтобы выход получать из ФОП)
т.о. надо будет ставить либы нормального XSLT
потому как нотусёвый, в жвм - полный УГ
сделал тайминг только трасформации:
-оригинал от афтора - 8 сек
-доработаный мной (повыкидывал ненужные раперы) - 6 сек
-LS (мой вариант): с обработкой DOM (выемка файлов) - 1,5 сек; без учёта - 1 сек

Добавлено: код афтора (добавил тайминг):<!--shcode--><pre><code class='java'>Timer timer=new Timer();
timer.start();
XSLProcessor xp = new XSLProcessor(new XML4JLiaison4dom());
StringReader xmlSource2 = new StringReader(newHTML);
StringReader xslSource2 = new StringReader(xslProfile.getItemValueString("RTXSL"));
StringWriter sw = new StringWriter();
XSLTInputSource xs = new XSLTInputSource(xmlSource2);
XSLTInputSource xt = new XSLTInputSource(xslSource2);
XSLTResultTarget tout = new XSLTResultTarget(sw);

xp.process(xs, xt, tout);
System.out.println(timer.stop());[/CODE]
исправленный вариант:<!--shcode--><pre><code class='java'> Timer timer=new Timer();
System.out.println("XSLT Transformation...");
timer.start();
//устанавливаем XSLT
transformer = transFact.newTransformer(new StreamSource(xslItem.getInputStream()));
transformer.transform(new StreamSource(fresult), new StreamResult(sw));

// код ниже не имеет преимуществ - т.к. нет других альтернативных процессоров в Нотусне
//org.apache.xalan.xslt.XSLTInputSource is=new org.apache.xalan.xslt.XSLTInputSource(domDoc);
//org.apache.xalan.xslt.XSLTProcessor xp = org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor( );
// XSLProcessor xp = new XSLProcessor(new XML4JLiaison4dom());
//XSLTInputSource xs = new XSLTInputSource(domDoc); //нет имплементации для прямой обработки (в Нотусне)
// XSLTInputSource xt = new XSLTInputSource(xslItem.getInputStream());
// XSLTResultTarget tout = new XSLTResultTarget(sw);
// xp.process(new XSLTInputSource(new FileInputStream(fresult)), xt, tout);
//xp.process(xs, xt, tout);
System.out.println(timer.stop());[/CODE]
 

lmike

нет, пердело совершенство
Lotus Team
27.08.2008
7 940
609
BIT
210
новая версия, включает в себя изменения, кот. были выше
не требует пересохранения дока - для отображения поля, это поведение было "заложено" (не знаю смысла) автором
дело в том, что, изначально, поле HTMLTransform создается как РТ, но отображаться во вью , такие поля, "не могут", а вот при пересохранении из web вью, подставляется др. форма, в кот. это поле - просто текст
в перспективе - отказ от отображения поля из вью может дать снятие ограничения на объем текста (хтмл, ~16К, т.к. русский язык, ну очень мало)
Если, всёже, надо выводить во вью - Ajax + js библиотеки - самый "правильный" способ...
файло Посмотреть вложение RT2Web.nsf.rar
 
Мы в соцсетях:

Обучение наступательной кибербезопасности в игровой форме. Начать игру!