我是否缺少一个步骤来处理 wso2esb 序列中的 xpath 表达式?
Am I missing a step in order to process xpath expression in a wso2esb sequence?
我已经搞砸了几个小时,我不确定问题出在哪里。现在我只是想记录一个 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)"
我能想到为什么这会崩溃:
- 您没有绑定命名空间,因此无论执行您的表达式,您的配置文件都不知道这些命名空间,除非它 "magically" 知道它们。
- 该工具的数据 "seen" 可能是实际的
rs:Data
,而不是还包括 xml
根节点和整个模式的整个数据集
因为我不知道您使用的环境,让我们重写您的表达式,使其独立于名称空间或根元素:
expression="count(/*//*[local-name(.) = 'data']/*[local-name(.) = 'row'])"
(在根节点后添加 //
以防结构与您显示的不同)如果即使失败,请考虑使用更荒谬的东西来确保甚至评估 XPath:
expression="concat('Hello world, count words: ', //@iWordCount[1])"
由于属性不在命名空间中,因此应该输出 iWordCount
的第一个值。如果returns为空,就知道你认为的文档有焦点,没有焦点。这是找出前三个元素名称的方法:
expression="concat('Hello: ', name(/*[1]), name(/*/*[2]), name(/*/*/*[1])"
这应该输出:"Hello: xml rs:data z:row"
如果不是,它至少应该指出您实际正在查看的数据。
我已经搞砸了几个小时,我不确定问题出在哪里。现在我只是想记录一个 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)"
我能想到为什么这会崩溃:
- 您没有绑定命名空间,因此无论执行您的表达式,您的配置文件都不知道这些命名空间,除非它 "magically" 知道它们。
- 该工具的数据 "seen" 可能是实际的
rs:Data
,而不是还包括xml
根节点和整个模式的整个数据集
因为我不知道您使用的环境,让我们重写您的表达式,使其独立于名称空间或根元素:
expression="count(/*//*[local-name(.) = 'data']/*[local-name(.) = 'row'])"
(在根节点后添加 //
以防结构与您显示的不同)如果即使失败,请考虑使用更荒谬的东西来确保甚至评估 XPath:
expression="concat('Hello world, count words: ', //@iWordCount[1])"
由于属性不在命名空间中,因此应该输出 iWordCount
的第一个值。如果returns为空,就知道你认为的文档有焦点,没有焦点。这是找出前三个元素名称的方法:
expression="concat('Hello: ', name(/*[1]), name(/*/*[2]), name(/*/*/*[1])"
这应该输出:"Hello: xml rs:data z:row"
如果不是,它至少应该指出您实际正在查看的数据。