Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 在每行换行的末尾添加加号_Json_Xml_Xslt - Fatal编程技术网

Json 在每行换行的末尾添加加号

Json 在每行换行的末尾添加加号,json,xml,xslt,Json,Xml,Xslt,我想在单句(单段落)中的换行结束处添加加号。有可能这样做吗 我的输入xml文件是: <response> <p>Developing additional problems with your health that are related to your diabetes is by no means a foregone conclusion. There is much you can do to lower your risk. By accepting

我想在单句(单段落)中的换行结束处添加加号。有可能这样做吗

我的输入xml文件是:

<response>
    <p>Developing additional problems with your health that are related to your diabetes is by no means a foregone conclusion. There is much you can do to lower your risk.  By accepting your diabetes diagnosis and educating yourself about the complications that can occur and how to prevent them, you have already taken an important first step.</p>
   </response>

这可能吗?如果是,请在这方面帮助我。提前感谢

这里是一个使用XSLT 2.0的示例和一个使用
xsl:analyze string
的函数,该函数使用正则表达式将字符串分解为具有特定限制的块(定义为整数参数):

我认为这个功能可以缩短为

<xsl:function name="mf:break" as="xs:string">
    <xsl:param name="input" as="xs:string"/>
    <xsl:value-of separator="{$sep}">
        <xsl:analyze-string select="$input" regex="{$pattern}">
            <xsl:matching-substring>
                <xsl:sequence select="concat('&quot;', regex-group(2), '&quot;')"/>
            </xsl:matching-substring>
        </xsl:analyze-string>
    </xsl:value-of>
</xsl:function>

“回应”:“与“+”糖尿病相关的其他健康问题绝不是定局。要降低“+”风险,你可以做很多事情。通过接受糖尿病诊断,并教育自己可能发生的“+”并发症以及如何预防,你已经采取了一项措施”+“重要的第一步。我想用单引号代替双引号。
   "response": "Developing additional problems with your health that are related to" + 
   "your diabetes is by no means a foregone conclusion. There is much you can do to" +
   "lower your risk.  By accepting your diabetes diagnosis and educating yourself" +
    "about the complications that can occur and how to prevent them, you have" + 
"already taken an important first step."
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mf="http://example.com/mf"
    exclude-result-prefixes="xs mf" version="2.0">

    <xsl:param name="length" as="xs:integer" select="80"/>

    <xsl:param name="pattern" as="xs:string" select="concat('((.{1,', $length, '})( |$))')"/>

    <xsl:param name="sep" as="xs:string" select="' + &#10;'"/>

    <xsl:output method="text"/>

    <xsl:function name="mf:break" as="xs:string">
        <xsl:param name="input" as="xs:string"/>
        <xsl:variable name="result">
            <xsl:analyze-string select="$input" regex="{$pattern}">
                <xsl:matching-substring>
                    <xsl:value-of select="concat('&quot;', regex-group(2), '&quot;')"/>
                    <xsl:if test="position() ne last()">
                        <xsl:value-of select="$sep"/>
                    </xsl:if>
                </xsl:matching-substring>
            </xsl:analyze-string>
        </xsl:variable>
        <xsl:sequence select="$result"/>
    </xsl:function>

    <xsl:template match="response">
        "response": <xsl:sequence select="mf:break(normalize-space())"/>
    </xsl:template>

</xsl:stylesheet>
        "response": "Developing additional problems with your health that are related to your" + 
"diabetes is by no means a foregone conclusion. There is much you can do to lower" + 
"your risk. By accepting your diabetes diagnosis and educating yourself about the" + 
"complications that can occur and how to prevent them, you have already taken an" + 
"important first step.
<xsl:function name="mf:break" as="xs:string">
    <xsl:param name="input" as="xs:string"/>
    <xsl:value-of separator="{$sep}">
        <xsl:analyze-string select="$input" regex="{$pattern}">
            <xsl:matching-substring>
                <xsl:sequence select="concat('&quot;', regex-group(2), '&quot;')"/>
            </xsl:matching-substring>
        </xsl:analyze-string>
    </xsl:value-of>
</xsl:function>