我是XQuery的新手,我无法从深层xml结构中获取数据:
以下是XML-Data:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!-- Eingangs-Message -->
<!-- root element -->
<syncBusinessPartner xmlns='http://crm.igepa.com' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<in0 xsi:type='ns1:AddressBookMaster' xmlns:ns1='http://data.common.jde.igepa.com'>
<ns1:AddressBookMaster xsi:type='ns1:AddressBookMaster'>
<ns1:GLBankAccount xsi:type='xsd:string'/>
<ns1:actionMessageControl xsi:type='xsd:string'/>
<ns1:addTypeCode4Purch xsi:type='xsd:string'>N</ns1:addTypeCode4Purch>
<ns1:addressByDate xsi:type='ns1:AddressByDate'>
<ns1:AddressByDate xsi:type='ns1:AddressByDate'>
<ns1:addressLine1 xsi:type='xsd:string'>FirmZus1 Abnahmetest 3 ATU </ns1:addressLine1>
<ns1:addressLine2 xsi:type='xsd:string'>FirmZus2 Abnahmetest 3 ATU </ns1:addressLine2>
<ns1:addressLine3 xsi:type='xsd:string'/>
<ns1:addressLine4 xsi:type='xsd:string'>Einzingergasse 4 </ns1:addressLine4>
<ns1:addressNumber xsi:type='xsd:string'>890193</ns1:addressNumber>
<ns1:bulkMailingCenter xsi:type='xsd:string'/>
<ns1:carrierRoute xsi:type='xsd:string'>S</ns1:carrierRoute>
<ns1:city xsi:type='xsd:string'>Wien </ns1:city>
<ns1:country xsi:type='xsd:string'>AT </ns1:country>
<ns1:countyAddress xsi:type='xsd:string'/>
<ns1:dateBeginningEffective xsi:type='xsd:string'>0</ns1:dateBeginningEffective>
<ns1:state xsi:type='xsd:string'/>
<ns1:zipCodePostal xsi:type='xsd:string'>1210 </ns1:zipCodePostal>
</ns1:AddressByDate>
</ns1:addressByDate>
<ns1:costCenter xsi:type='xsd:string'> 202</ns1:costCenter>
<ns1:creditMessage xsi:type='xsd:string'/>
<ns1:crmPositions xsi:type='ns1:CRMPositions'>
<ns1:CRMPositions xsi:type='ns1:CRMPositions'>
<ns1:addressNumber xsi:type='xsd:string'>890193</ns1:addressNumber>
<ns1:commissionCode1 xsi:type='xsd:string'>0</ns1:commissionCode1>
<ns1:commissionCode2 xsi:type='xsd:string'>42666</ns1:commissionCode2>
<ns1:costCenter xsi:type='xsd:string'>202 </ns1:costCenter>
<ns1:crmPositionen xsi:type='xsd:string'>S42666 - 202 - Team Karton Dortmund </ns1:crmPositionen>
<ns1:everestEventPoint01 xsi:type='xsd:string'>1</ns1:everestEventPoint01>
<ns1:everestEventPoint02 xsi:type='xsd:string'>K</ns1:everestEventPoint02>
<ns1:everestEventPoint03 xsi:type='xsd:string'>C</ns1:everestEventPoint03>
<ns1:productCode xsi:type='xsd:string'/>
<ns1:userDefinedCode xsi:type='xsd:string'/>
<ns1:userDefinedCodes xsi:type='xsd:string'/>
</ns1:CRMPositions>
</ns1:crmPositions>
<ns1:customerMaster xsi:type='ns1:CustomerMaster'>
<ns1:ARClass xsi:type='xsd:string'/>
<ns1:ARHoldInvoices xsi:type='xsd:string'>N</ns1:ARHoldInvoices>
<ns1:TRWDate xsi:type='xsd:string'>0</ns1:TRWDate>
</ns1:customerMaster>
<ns1:dateBeginningEffective xsi:type='xsd:string'>0</ns1:dateBeginningEffective>
<ns1:dateScheduledIn xsi:type='xsd:string'>0</ns1:dateScheduledIn>
<ns1:kanijAlpha xsi:type='xsd:string'/>
<ns1:languagePreference xsi:type='xsd:string'>G </ns1:languagePreference>
<ns1:miscCode3 xsi:type='xsd:string'/>
<ns1:nameAlpha xsi:type='xsd:string'>ft abnahmetest3_ATU </ns1:nameAlpha>
<ns1:nameRemark xsi:type='xsd:string'/>
<ns1:personCorporationCode xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook001 xsi:type='xsd:string'>20 </ns1:reportCodeAddressBook001>
<ns1:reportCodeAddressBook002 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook003 xsi:type='xsd:string'>Yep</ns1:reportCodeAddressBook003>
<ns1:reportCodeAddressBook004 xsi:type='xsd:string'>BOO</ns1:reportCodeAddressBook004>
<ns1:reportCodeAddressBook005 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook006 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook007 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook008 xsi:type='xsd:string'>902</ns1:reportCodeAddressBook008>
<ns1:reportCodeAddressBook009 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook010 xsi:type='xsd:string'>N </ns1:reportCodeAddressBook010>
<ns1:reportCodeAddressBook011 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook012 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook013 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook014 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook015 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook016 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook017 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook018 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook019 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook020 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook021 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook022 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook023 xsi:type='xsd:string'>5 </ns1:reportCodeAddressBook023>
<ns1:reportCodeAddressBook024 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook025 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook026 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook027 xsi:type='xsd:string'>M2 </ns1:reportCodeAddressBook027>
<ns1:reportCodeAddressBook028 xsi:type='xsd:string'>J </ns1:reportCodeAddressBook028>
<ns1:reportCodeAddressBook029 xsi:type='xsd:string'/>
<ns1:reportCodeAddressBook030 xsi:type='xsd:string'>200</ns1:reportCodeAddressBook030>
<ns1:subledgerInactiveCode xsi:type='xsd:string'/>
<ns1:taxID xsi:type='xsd:string'>AT10203040 </ns1:taxID>
<ns1:taxID2 xsi:type='xsd:string'/>
<ns1:timeScheduledIn xsi:type='xsd:string'>0</ns1:timeScheduledIn>
<ns1:whoIsWho xsi:type='ns1:whoIsWho'>
<ns1:WhoIsWho xsi:type='ns1:WhoIsWho'>
<ns1:addressNumber xsi:type='xsd:string'>890193</ns1:addressNumber>
<ns1:categoryCodeWhosWho001 xsi:type='xsd:string'/>
<ns1:categoryCodeWhosWho002 xsi:type='xsd:string'/>
<ns1:categoryCodeWhosWho003 xsi:type='xsd:string'/>
<ns1:categoryCodeWhosWho004 xsi:type='xsd:string'/>
<ns1:categoryCodeWhosWho005 xsi:type='xsd:string'/>
<ns1:categoryCodeWhosWho006 xsi:type='xsd:string'/>
<ns1:categoryCodeWhosWho007 xsi:type='xsd:string'/>
<ns1:categoryCodeWhosWho008 xsi:type='xsd:string'/>
<ns1:categoryCodeWhosWho009 xsi:type='xsd:string'/>
<ns1:categoryCodeWhosWho010 xsi:type='xsd:string'/>
<ns1:contactPhoneNumbers xsi:type='ns1:ContactPhoneNumbers'>
<ns1:ContactPhoneNumbers xsi:type='ns1:ContactPhoneNumbers'>
<ns1:addressNumber xsi:type='xsd:string'>890193</ns1:addressNumber>
<ns1:lineNumberID xsi:type='xsd:string'>0</ns1:lineNumberID>
<ns1:phoneAreaCode xsi:type='xsd:string'>0043 </ns1:phoneAreaCode>
<ns1:phoneNumber xsi:type='xsd:string'>12030405010 </ns1:phoneNumber>
<ns1:phoneNumberType xsi:type='xsd:string'>FAX </ns1:phoneNumberType>
<ns1:sequenceNumber xsi:type='xsd:string'>2</ns1:sequenceNumber>
<ns1:contactPersonalID xsi:type='xsd:string'>0</ns1:contactPersonalID>
<ns1:userID xsi:type='xsd:string'>ALENCLUD </ns1:userID>
<ns1:programID xsi:type='xsd:string'>EP01012 </ns1:programID>
<ns1:workStationID xsi:type='xsd:string'>S250AP50 </ns1:workStationID>
<ns1:dateUpdated xsi:type='xsd:string'>115056</ns1:dateUpdated>
<ns1:timeLastUpdated xsi:type='xsd:string'>114648</ns1:timeLastUpdated>
</ns1:ContactPhoneNumbers>
<ns1:ContactPhoneNumbers xsi:type='ns1:ContactPhoneNumbers'>
<ns1:addressNumber xsi:type='xsd:string'>890193</ns1:addressNumber>
<ns1:lineNumberID xsi:type='xsd:string'>0</ns1:lineNumberID>
<ns1:phoneAreaCode xsi:type='xsd:string'>0043 </ns1:phoneAreaCode>
<ns1:phoneNumber xsi:type='xsd:string'>120304050 </ns1:phoneNumber>
<ns1:phoneNumberType xsi:type='xsd:string'/>
<ns1:sequenceNumber xsi:type='xsd:string'>1</ns1:sequenceNumber>
<ns1:contactPersonalID xsi:type='xsd:string'>0</ns1:contactPersonalID>
<ns1:userID xsi:type='xsd:string'>ALENCLUD </ns1:userID>
<ns1:programID xsi:type='xsd:string'>EP01012 </ns1:programID>
<ns1:workStationID xsi:type='xsd:string'>S250AP50 </ns1:workStationID>
<ns1:dateUpdated xsi:type='xsd:string'>115056</ns1:dateUpdated>
<ns1:timeLastUpdated xsi:type='xsd:string'>114648</ns1:timeLastUpdated>
</ns1:ContactPhoneNumbers>
</ns1:contactPhoneNumbers>
<ns1:contactTitle xsi:type='xsd:string'/>
<ns1:descritptionCompressed xsi:type='xsd:string'>FT ABNAHMETEST3_ATU </ns1:descritptionCompressed>
<ns1:electronicAddress xsi:type='ns1:electronicAddress'>
<ns1.ElectronicAddress xsi:type='ns1:ElectronicAddress'>
<ns1:addressNumber xsi:type='xsd:string'>890193</ns1:addressNumber>
<ns1:electronicAddressType xsi:type='xsd:string'>I</ns1:electronicAddressType>
<ns1:emailAddress xsi:type='xsd:string'>www.igepa-its.de</ns1:emailAddress>
<ns1:lineNumberID xsi:type='xsd:string'>0</ns1:lineNumberID>
<ns1:sequenceNumber xsi:type='xsd:string'>1</ns1:sequenceNumber>
</ns1.ElectronicAddress>
</ns1:electronicAddress>
<ns1:kanijalpha xsi:type='xsd:string'/>
<ns1:lineNumberID xsi:type='xsd:string'>0</ns1:lineNumberID>
<ns1:nameAlpha xsi:type='xsd:string'>ft abnahmetest3_ATU </ns1:nameAlpha>
<ns1:nameGiven xsi:type='xsd:string'/>
<ns1:nameMailing xsi:type='xsd:string'>Firma Abnahmetest 3 ATU </ns1:nameMailing>
<ns1:nameMiddle xsi:type='xsd:string'/>
<ns1:nameSurname xsi:type='xsd:string'/>
<ns1:remark1 xsi:type='xsd:string'/>
<ns1:salutationName xsi:type='xsd:string'/>
<ns1:secondMailingName xsi:type='xsd:string'/>
<ns1:sequenceNumber xsi:type='xsd:string'>0.00</ns1:sequenceNumber>
<ns1:typeCode xsi:type='xsd:string'/>
<ns1:userID xsi:type='xsd:string'>ALENCLUD </ns1:userID>
<ns1:programID xsi:type='xsd:string'>EP01012 </ns1:programID>
<ns1:workStationID xsi:type='xsd:string'>S250AP50 </ns1:workStationID>
<ns1:dateUpdated xsi:type='xsd:string'>115056</ns1:dateUpdated>
<ns1:timeLastUpdated xsi:type='xsd:string'>114648</ns1:timeLastUpdated>
<ns1:contactType xsi:type='xsd:string'/>
<ns1:nickName xsi:type='xsd:string'/>
<ns1:gender xsi:type='xsd:string'/>
<ns1:dateOfBirth xsi:type='xsd:string'>0</ns1:dateOfBirth>
<ns1:monthOfBirth xsi:type='xsd:string'>0</ns1:monthOfBirth>
<ns1:yearOfBirth xsi:type='xsd:string'>0</ns1:yearOfBirth>
<ns1:categoryCode01 xsi:type='xsd:string'/>
<ns1:categoryCode02 xsi:type='xsd:string'/>
<ns1:categoryCode03 xsi:type='xsd:string'/>
<ns1:categoryCode04 xsi:type='xsd:string'/>
<ns1:categoryCode05 xsi:type='xsd:string'/>
<ns1:categoryCode06 xsi:type='xsd:string'/>
<ns1:categoryCode07 xsi:type='xsd:string'/>
<ns1:categoryCode08 xsi:type='xsd:string'/>
<ns1:categoryCode09 xsi:type='xsd:string'/>
<ns1:categoryCode10 xsi:type='xsd:string'/>
<ns1:functionCode xsi:type='xsd:string'/>
<ns1:preferedContactMethod xsi:type='xsd:string'/>
<ns1:primaryContact xsi:type='xsd:string'>0 </ns1:primaryContact>
<ns1:futureUseIndicator xsi:type='xsd:string'/>
<ns1:uniqueIdentifier xsi:type='xsd:string'/>
<ns1:synchronizationStatus xsi:type='xsd:string'>0</ns1:synchronizationStatus>
<ns1:serverStatus xsi:type='xsd:string'>0</ns1:serverStatus>
</ns1:WhoIsWho>
</ns1:whoIsWho>
</ns1:AddressBookMaster>
</in0>
<in1>
<string xsi:type='xsd:string'>crm_ig</string>
</in1>
</syncBusinessPartner>
我想从electronicAddress元素获取带有lineNumberID ='0'和electronicAddressType ='I'的电子邮件地址
在我看来,我必须通过electronicAddress循环遍历whoIsWho和WhoIsWho内的每个WhoIsWho元素,我期待以下结果
<ige:HomePage>www.webaddress.de</ige:HomePage>
我的XQuery:
xquery version "1.0" encoding "utf-8";
(:: OracleAnnotationVersion "1.0" ::)
declare namespace ns1="http://crm.igepa.com";
(:: import schema at "../ProxyService/WSDL/IGEPA_PS_WSDL_BUSINESSPARTNER_E1_9_0_V1R0.wsdl" ::)
declare namespace ns2="http://siebel.com/CustomUI";
(:: import schema at "../BusinessService/WSDL/IGEPA_BS_WSDL_BUSINESSPARTNER_E1_9_0_V1R0.wsdl" ::)
declare namespace ige = "http://www.siebel.com/xml/IGEPA%20Firmen%20WS%20Inbound%20IO";
declare namespace dat = "http://data.common.jde.igepa.com";
declare namespace functx = "http://www.functx.com";
declare variable $mapBusinessPartner as element() (:: schema-element(ns1:syncBusinessPartner) ::) external;
declare function local:func($mapBusinessPartner as element() (:: schema-element(ns1:syncBusinessPartner) ::)) as element() (:: schema-element(ns2:IGEPAFirmenWSInboundSyncBusinessPartnerToCRM_1_Input) ::) {
<ns2:IGEPAFirmenWSInboundSyncBusinessPartnerToCRM_1_Input>
<ige:ListOfIgepaFirmenWsInboundIo>{
for $AddressBookMaster in $mapBusinessPartner/ns1:in0/dat:AddressBookMaster
return <ige:Account>
<ige:HomePage>{
data($AddressBookMaster/dat:whoIsWho/dat:WhoIsWho/dat:electronicAddress/dat:ElectronicAddress[dat:lineNumberID = "0" and dat:electronicAddressType = "I"]/dat:emailAddress)
}
</ige:HomePage>
</ige:Account>
}
</ige:ListOfIgepaFirmenWsInboundIo></ns2:IGEPAFirmenWSInboundSyncBusinessPartnerToCRM_1_Input>
};
local:func($mapBusinessPartner)
答案 0 :(得分:0)
你正在做的是让你描述的东西复杂化。这可以通过简单的XPath表达式完成。不需要for循环,你可能会更多地阅读XPath和XQuery,因为你似乎错过了一些重要的概念。
您可以使用/
步骤选择一些子元素,并在括号[]
中添加条件。使用data()
或string()
只提供数据元素,而不是XML元素。
declare namespace dat = "http://data.company.com";
<ige:HomePage>{
/element/in0/dat:AddressBook/dat:whoIsWho/dat:WhoIsWho/dat:electronicAddress/dat:ElectronicAddress[dat:lineNumberID = 0 and dat:electronicAddressType = "I"]/dat:emailAddress/data()
}</ige:HomePage>