简体   繁体   English

WSO2 XSLT介体子字符串-制表符分隔的字符串之前

[英]WSO2 XSLT Mediator substring-before tab separated string

I'm trying to split a tab separated value string using substring-before I'm having a hard time because the XSLT mediator does not work as it should. 我正在尝试使用substring拆分制表符分隔的值字符串-在遇到麻烦之前,因为XSLT介体无法正常工作。

The xslt stylesheet: xslt样式表:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:p576="http://p576.test.ws" version="1.0">
 <xsl:output encoding="UTF-8" method="xml" indent="yes"></xsl:output>

  <xsl:param name="NAMESPACE"></xsl:param>
  <xsl:param name="LOG_ID"></xsl:param>

  <xsl:template match="/">
    <xsl:element name="Response" namespace="{$NAMESPACE}">
      <xsl:if test="$LOG_ID">
        <xsl:element name="LogId" namespace="{$NAMESPACE}">
           <xsl:value-of select="$LOG_ID"></xsl:value-of>
        </xsl:element>
     </xsl:if>
     <xsl:element name="Text" namespace="{$NAMESPACE}">
        <xsl:value-of select="substring-before(//p576:execMRPCResponse/p576:execMRPCReturn, '&#x9;')"></xsl:value-of>
     </xsl:element>
   </xsl:element>
  </xsl:template>

</xsl:stylesheet>

The string: 字符串:

999900418559    59  4730    Payment Created &amp; Posted

Instead of cutting the string "999900418559" it cuts it here: "999900418559 59 4730 Payment" where a space is. 而不是剪切字符串“ 999900418559”,而是在此处剪切:“ 999900418559 59 4730付款”,在空格处。 The same result is achieved if you use substring-before '$#32;' 如果在'$#32;'之前使用substring,也会获得相同的结果。 meaning tab and space are converted to space when looking into the string. 表示在查看字符串时,制表符和空格会转换为空格。

Is there any way to keep this from happening? 有什么办法可以防止这种情况发生? or if the problem is with the version of saxon used by wso2, should I update it (I'm using WSO2ESB v4.8.1)? 还是如果问题与wso2使用的saxon版本有关,我应该更新它(我正在使用WSO2ESB v4.8.1)吗?

If tabs in the source document are being converted to spaces, then this is happening before Saxon gets to see the data. 如果将源文档中的选项卡转换为空格,则这是在Saxon查看数据之前发生的。 It could happen, for example, if the data is put through a schema validator and the type of the relevant element uses a whitespace facet of "collapse". 例如,如果通过架构验证器放置数据,并且相关元素的类型使用“折叠”的空白构面,则可能会发生这种情况。

To prevent it happening, you first need to find out when and where it is happening, and there are no clues to that in your post (at least for someone who has never heard of WSO2ESB). 为了防止它发生,您首先需要找出它发生的时间和地点,并且您的帖子中没有任何线索(至少对于从未听说过WSO2ESB的人来说)。

As a first diagnostic step, try to capture the exact form of the source document supplied as input to the transformation, and check the state of the whitespace it contains. 作为第一步诊断,请尝试捕获作为转换输入提供的源文档的确切形式,并检查其中包含的空白状态。

Having written that, I think there is another possibility, which is that the &#x9; 写完这些之后,我认为还有另一种可能性,即&#x9; character reference in your stylesheet is being corrupted by whatever process it is that compiles the stylesheet. 样式表中的任何字符引用都被编译样式表的任何过程破坏。 You could defend against that by replacing '&#x9;' 您可以通过替换'&#x9;'对此进行辩护 with codepoints-to-string(9) . codepoints-to-string(9)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM