2017-01-31 2 views
0

Мне нужно добавить символ «+» только между условием многократного Para, в случае, если единственное условие п нужно пренебрегать СимволомНеобходимо обеспечить символ для конкретного экземпляра

Мой XML Входной файл:

<text> 
<top> 
<p>This thesis statement is not your main point; it is the main point of your source.</p> 
</top> 
<bottom> 
<p>Combine sentences in Step Two to form your summary; organize your summary sentences.</p> 
<p>Summaries differ from more closely follow the original text's presentation.</p> 
</bottom> 
</text> 

XSL Я использовал как:

<xsl:stylesheet version="3.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:json="http://json.org/" xmlns:mf="http://example.com/mf" 
exclude-result-prefixes="#all"> 

<xsl:template match="text"> 
    text: { 
    <xsl:apply-templates/> 
    }, 
</xsl:template> 

<xsl:template match="top"> 
    "top": <xsl:apply-templates/>, 
</xsl:template> 

<xsl:template match="bottom"> 
    "bottom": <xsl:apply-templates/>, 
</xsl:template> 

<xsl:template match="p"> 
    <xsl:variable name="span"> 
    <span> 
    <xsl:apply-templates/> 
    </span> 
    </xsl:variable> 
    <xsl:text>&#10;</xsl:text> 
    <xsl:sequence select="mf:break(normalize-space(serialize($span, $ser-params)))"/> 
    <xsl:if test="position() != 2">+</xsl:if> 
</xsl:template> 

</xsl:stylesheet> 

Выход я получил как:

text: { 

"top": 
"<span>This thesis statement is not your main point; it is the main" + 
"point of your source.</span>"+, 

"bottom": 
"<span>Combine sentences in Step Two to form your summary; organize" + 
"your summary sentences.</span>"+ 
"<span>Summaries differ from more closely follow the original text's" + 
"presentation.</span>", 

}, 

Ожидаемый результат:

text: { 

"top": 
"<span>This thesis statement is not your main point; it is the main" + 
"point of your source.</span>", 

"bottom": 
"<span>Combine sentences in Step Two to form your summary; organize" + 
"your summary sentences.</span>"+ 
"<span>Summaries differ from more closely follow the original text's" + 
"presentation.</span>", 

}, 

+ символ должен прийти между пара-х годов. Im Использование Saxon-PE 9.6.0.7. Пожалуйста, поделитесь некоторыми идеями относительно этого. Заранее спасибо

ответ

0

Проверить последний <p> элемент, как:

<xsl:if test="position() != last()">+</xsl:if> 
Смежные вопросы