gpt4 book ai didi

xpath - 我是否错过了处理 wso2esb 序列中的 xpath 表达式的步骤?

转载 作者:行者123 更新时间:2023-12-03 16:29:14 24 4
gpt4 key购买 nike

我已经搞砸了几个小时,我不确定问题是什么。现在我只是想记录一个 XML 文件的 xpath 表达式的结果,该表达式从代理传递到一个序列。到目前为止,我的表情没有记录任何内容。我已经以几种不同的方式更改了表达式和命名空间,但我无法让信息显示在日志中。我可以看到正在记录的 XML 文件是完整的,但不是我试图用 xpath 提取的数据。当我在插件中运行 xpath 时,我能够很好地提取数据,所以我认为这不是实际表达式的问题。

谁能把我推向正确的方向?我猜这可能是 XML 格式或命名空间的问题,但我不能 100% 确定。

谢谢你。

顺序

<sequence xmlns="http://ws.apache.org/ns/synapse" name="MySequence">
<log level="custom">
<property name="sequence" value="MySequence"></property>
</log>
<property xmlns:ns="http://org.apache.synapse/xsd" name="filename" expression="get-property('transport', 'FILE_NAME')"></property>
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="show-name" expression="get-property('filename')"></property>
<property xmlns:ns="http://org.apache.synapse/xsd" name="file-name" expression="get-property('targetfilename')"></property>
</log>
<log level="custom">
<property xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:ns="http://org.apache.synapse/xsd" xmlns:z="RowsetSchema"
name="sequenceExp" expression="count(//xml/rs:data/z:row)"></property>
</log>
<property xmlns:ns2="http://org.apache.synapse/xsd"
xmlns:ns="http://org.apache.synapse/xsd"
name="transport.vfs.ReplyFileName" expression="fn:concat(get-
property('SYSTEM_DATE', 'yyMMddHHmmss'), '-',
get-property('filename'))"
scope="transport"></property>
<property name="OUT_ONLY" value="true"></property>
<send>
<endpoint name="FileEpr">
<address uri="vfs:file:///var/process/rrout"></address>
</endpoint>
</send>
</sequence>

XML 输入数据(以模式开头, xml 元素的第二个子元素是实际数据)
<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='RowsetSchema'>
<s:schema id='RowsetSchema'>
<s:elementType name='row' content='eltOnly'>
<s:attributeType name='iQuizID' rs:number='1'
rs:writeunknown='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='iALSQuizNumber' rs:number='2' rs:writeunknown='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='iBookID' rs:number='3' rs:writeunknown='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='vchBookType' rs:number='4' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10'/>
</s:attributeType>
<s:attributeType name='vchQuizType' rs:number='5'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='2'
rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='vchQuizTypeDesc' rs:number='6'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'
rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='tiShowPointsInAR' rs:number='7'
rs:writeunknown='true'>
<s:datatype dt:type='ui1' dt:maxLength='1' rs:precision='3'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='tiAudioEnabled' rs:number='8'
rs:writeunknown='true'>
<s:datatype dt:type='ui1' dt:maxLength='1' rs:precision='3'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='tiAudioStatus' rs:number='9'
rs:writeunknown='true'>
<s:datatype dt:type='ui1' dt:maxLength='1' rs:precision='3'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='chTitlePrefix' rs:number='10'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='5'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='vchBookTitle' rs:number='11'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='255'
rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='vchAuthorFirstName' rs:number='12'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='30'
rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='vchAuthorMiddleName' rs:number='13'
rs:nullable='true' rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='30'/>
</s:attributeType>
<s:attributeType name='vchAuthorLastName' rs:number='14'
rs:nullable='true' rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='30'/>
</s:attributeType>
<s:attributeType name='vchLanguageCode' rs:number='15'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='4'
rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='vchLanguage' rs:number='16'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'
rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='iFiction' rs:number='17'
rs:writeunknown='true'>
<s:datatype dt:type='ui1' dt:maxLength='1' rs:precision='3'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='vchFiction' rs:number='18'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='20'
rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='tiOutOfPrint' rs:number='19'
rs:writeunknown='true'>
<s:datatype dt:type='ui1' dt:maxLength='1' rs:precision='3'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='vchOutOfPrint' rs:number='20'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='20'
rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='iReadingLevel' rs:number='21'
rs:writeunknown='true'>
<s:datatype dt:type='float' dt:maxLength='8' rs:precision='15'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='vchInterestLevel' rs:number='22'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10'
rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='iARPoints' rs:number='23'
rs:writeunknown='true'>
<s:datatype dt:type='float' dt:maxLength='8' rs:precision='15'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='flATOS' rs:number='24' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='float' dt:maxLength='8' rs:precision='15'
rs:fixedlength='true'/>
</s:attributeType>
<s:attributeType name='txBookSummary' rs:number='25'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str'
dt:maxLength='2147483647' rs:long='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='iWordCount' rs:number='26'
rs:writeunknown='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='iNumberQuestions' rs:number='27'
rs:writeunknown='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='iQuizStatus' rs:number='28'
rs:writeunknown='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='dtOriginalApprovalDate' rs:number='29'
rs:nullable='true' rs:writeunknown='true'>
<s:datatype dt:type='dateTime' rs:dbtype='timestamp'
dt:maxLength='16' rs:scale='3' rs:precision='23'
rs:fixedlength='true'/>
</s:attributeType>
<s:attributeType name='vchDifficultyLevel' rs:number='30'
rs:nullable='true' rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='30'/>
</s:attributeType>
<s:attributeType name='vchQuizISBN' rs:number='31'
rs:nullable='true' rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='25'/>
</s:attributeType>
<s:attributeType name='iContentID' rs:number='32'
rs:writeunknown='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='tiRecordStatus' rs:number='33'
rs:writeunknown='true'>
<s:datatype dt:type='ui1' dt:maxLength='1' rs:precision='3'
rs:fixedlength='true' rs:maybenull='false'/>
</s:attributeType>
<s:attributeType name='vchBookTitleContrived' rs:number='34'
rs:nullable='true' rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str'
dt:maxLength='1024'/>
</s:attributeType>
<s:attributeType name='vchAuthorContrived' rs:number='35'
rs:nullable='true' rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='500'/>
</s:attributeType>
<s:attributeType name='vchCountry' rs:number='36' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10'/>
</s:attributeType>
<s:attributeType name='iSponsor' rs:number='37' rs:nullable='true'
rs:writeunknown='true'>
<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
rs:fixedlength='true'/>
</s:attributeType>
<s:attributeType name='dtLastApprovalDate' rs:number='38'
rs:nullable='true' rs:writeunknown='true'>
<s:datatype dt:type='dateTime' rs:dbtype='timestamp'
dt:maxLength='16' rs:scale='3' rs:precision='23'
rs:fixedlength='true'/>
</s:attributeType>
<s:extends type='rs:rowbase'/>
</s:elementType>
</s:schema>
<rs:data>
<z:row iQuizID='18636' iALSQuizNumber='1' iBookID='3093' vchBookType=' '
vchQuizType='RP' vchQuizTypeDesc='Reading Practice'
tiShowPointsInAR='1' tiAudioEnabled='0' tiAudioStatus='0'
chTitlePrefix=' ' vchBookTitle='Adam of the Road'
vchAuthorFirstName='Elizabeth' vchAuthorMiddleName='Janet'
vchAuthorLastName='Gray' vchLanguageCode='EN' vchLanguage='English'
iFiction='1' vchFiction='Fiction' tiOutOfPrint='0'
vchOutOfPrint='In Print' iReadingLevel='6.5' vchInterestLevel='MG'
iARPoints='9' flATOS='9' txBookSummary='This book describes the
adventures of eleven-year-old Adam as he travels the open roads of
thirteenth-century England searching for his missing father, a minstrel,
and his stolen red spaniel, Nick.'
iWordCount='57357' iNumberQuestions='10' iQuizStatus='1'
dtOriginalApprovalDate='1996-04-10T00:00:00' vchDifficultyLevel=' '
vchQuizISBN=' ' iContentID='118636' tiRecordStatus='1'
vchCountry='US;CA' dtLastApprovalDate='2000-02-24T00:00:00'/>
<z:row iQuizID='18637' iALSQuizNumber='2' iBookID='3094' vchBookType=' '
vchQuizType='RP' vchQuizTypeDesc='Reading Practice'
tiShowPointsInAR='1' tiAudioEnabled='0' tiAudioStatus='0'
chTitlePrefix=' ' vchBookTitle='All-of-a-Kind Family'
vchAuthorFirstName='Sydney' vchAuthorMiddleName=''
vchAuthorLastName='Taylor' vchLanguageCode='EN' vchLanguage='English'
iFiction='1' vchFiction='Fiction' tiOutOfPrint='0'
vchOutOfPrint='In Print' iReadingLevel='4.9000000000000004'
vchInterestLevel='MG' iARPoints='5' flATOS='5' txBookSummary='Five
girls have simple but happy times, with parents rich in kindness but
poor in money.'
iWordCount='32006' iNumberQuestions='10' iQuizStatus='1'
dtOriginalApprovalDate='1996-04-10T00:00:00' vchDifficultyLevel=' '
vchQuizISBN=' ' iContentID='118637' tiRecordStatus='1'
vchCountry='US;CA' dtLastApprovalDate='1996-09-19T00:00:00'/>
</rs:data>
</xml>

- - - - - 编辑
您可以通过将代理中的 contentType 更改为“application/xml”来解决此问题。

最佳答案

expression="count(//xml/rs:data/z:row)"


我可以想到为什么这会破坏的几件事:
  • 你没有绑定(bind)命名空间,所以无论执行你的表达式,你的配置文件都不知道这些命名空间,除非它“神奇地”知道它们。
  • 该工具“看到”的数据可能是实际的 rs:Data ,而不是包含 xml 的全部内容根节点和整个架构

  • 因为我不知道您使用的环境,所以让我们以独立于命名空间或根元素的方式重写您的表达式:
    expression="count(/*//*[local-name(.) = 'data']/*[local-name(.) = 'row'])"

    (添加 // 在根节点之后,以防结构与您显示的不同)如果即使这样也失败了,请考虑使用更荒谬的东西来确保甚至评估 XPath:
    expression="concat('Hello world, count words: ', //@iWordCount[1])"

    由于属性不在命名空间中,这应该输出 iWordCount 的第一个值.如果它返回空,你知道你认为的文档有焦点,没有焦点。这是找出前三个元素名称的方法:
    expression="concat('Hello: ', name(/*[1]), name(/*/*[2]), name(/*/*/*[1])"

    这应该输出: "Hello: xml rs:data z:row"
    如果不是,它至少应该指出您实际查看的数据。

    关于xpath - 我是否错过了处理 wso2esb 序列中的 xpath 表达式的步骤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32665189/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com