2011-02-03 13 views
0

XQuery変換(OSBのXQuery実装に違いがある場合)を実行しようとするとXP0006エラーが発生し、解決に時間が掛かります。XQuery変換でXP0006エラーが発生しました。

与えられたエラーは私の知る限り、このエラーの原因を言うことができるように

<error>Error occurred while executing XQuery: {err}XP0006: "element {http://www.websitename.com/claims/client/UpdateClient.xsd}updateClient { {http://www.w3.org/2004/07/xpath-datatypes}untypedAny }": bad value for type element {http://www.websitename.com/claims/client/UpdateClient}updateClient { {http://www.w3.org/2001/XMLSchema}anyType }</error> 

である私のソースXMLファイルは複数の名前空間が含まれているという事実です。ネームスペースが1つしかないXMLファイルで実行されている別の変換が正常に実行されています。ここで

は私に迷惑を与えている変換です:ここでは

(:: pragma bea:global-element-parameter parameter="$updateClient1" element="ns0:updateClient" location="../xsd/claims/client/UpdateClient.xsd" ::) 
(:: pragma bea:global-element-return element="ns3:TemplateUpdateClient-WrkFrm" location="../xsd/claims/templates/wc/UpdateClient.xsd" ::) 

declare namespace ns2 = "http://www.websitename.com/common/customDataTypes"; 
declare namespace ns1 = "http://www.websitename.com/document/production/common/customDataTypes"; 
declare namespace ns3 = "http://www.websitename.com/document/production/template/templateupdateclient"; 
declare namespace ns0 = "http://www.websitename.com/claims/client/UpdateClient"; 
declare namespace xf = "http://tempuri.org/DocumentSubmissionConversionOSB/XQuery/WCtest/"; 

(:~ 
: This function converts a set of strings describing 
: an address into the new address format 
: 
: @param $recipient the addressee 
: @param $line1 address Line#1 
: @param $line2 address Line#2 
: @param $lnie3 address Line#3 
: @param $city the city 
: @param $provinceOrState the province (if CA) or state (if US) 
: @param $country the country (CA, US, or something else) 
: @param $postalOrZIP the postal code (if CA or other) or zip code (if US) 
: @return either a <CanadanAddress>, a <USAddress>, or an <InternationalAddress> depending on the country 
:) 
declare function local:to-address(
    $recipient as xs:string, 
    $line1 as xs:string, 
    $line2 as xs:string, 
    $line3 as xs:string, 
    $city as xs:string, 
    $provinceOrState as xs:string, 
    $country as xs:string, 
    $postalOrZIP as xs:string 
) 
as element() { 
    if (fn:upper-case($country) = 'CA') then 
     <CanadianAddress> 
      <City>{ $city }</City> 
      <Country>{ $country }</Country> 
      <PostalCode>{ $postalOrZIP }</PostalCode> 
      <Province>{ $provinceOrState }</Province> 
      <Recipient>{ $recipient }</Recipient> 
      <StreetAddress>{ $line1 }</StreetAddress> 
      <StreetAddress>{ $line2 }</StreetAddress> 
      <StreetAddress>{ $line3 }</StreetAddress> 
      <StreetAddress/> 
     </CanadianAddress> 
    else 
     if (fn:upper-case($country) = 'US') then 
      <USAddress> 
       <City>{ $city }</City> 
       <Country>{ $country }</Country> 
       <ZipCode>{ $postalOrZIP }</ZipCode> 
       <State>{ $provinceOrState }</State> 
       <Recipient>{ $recipient }</Recipient> 
       <StreetAddress>{ $line1 }</StreetAddress> 
       <StreetAddress>{ $line2 }</StreetAddress> 
       <StreetAddress>{ $line3 }</StreetAddress> 
      </USAddress>   
     else   
      <InternationalAddress> 
       <City>{ $city }</City> 
       <Country>{ $country }</Country> 
       <PostalCode>{ $postalOrZIP }</PostalCode> 
       <Recipient>{ $recipient }</Recipient> 
       <StreetAddress>{ $line1 }</StreetAddress> 
       <StreetAddress>{ $line2 }</StreetAddress> 
       <StreetAddress>{ $line3 }</StreetAddress> 
      </InternationalAddress> 
     (:endif:) 
    (:endif:) 
}; 

declare function xf:WCtest($updateClient1 as element(ns0:updateClient)) 
    as element(ns3:TemplateUpdateClient-WrkFrm) { 
     <ns3:TemplateUpdateClient-WrkFrm> 
      { 
       let $Client := $updateClient1/ns0:Client 
       return 
        <Client> 
         <ClaimNumber>{ data($Client/ns0:claimNumber) }</ClaimNumber> 
         <Gender>{ data($Client/ns0:gender) }</Gender> 
         <MaritalStatus>{ data($Client/ns0:maritalStatus)}</MaritalStatus> 
         { 
          let $fullName := $Client/ns0:fullName 
          return 
           <Name> 
            <FirstName>{ data($fullName/ns0:firstName) }</FirstName> 
            <LastName>{ data($fullName/ns0:lastName) }</LastName> 
            <MiddleInitial>{ data($fullName/ns0:middleName) }</MiddleInitial> 
           </Name> 
         } 
         <SIN>{ data($Client/ns0:SIN) }</SIN> 
         { 
          let $currentAddress := $Client/ns0:currentAddress 
          return 
           <CurrentAddress>{ 
            local:to-address(
             data($currentAddress/ns2:line1), 
             data($currentAddress/ns2:line2), 
             data($currentAddress/ns2:line3), 
             data($currentAddress/ns2:city), 
             data($currentAddress/ns2:provinceOrState), 
             data($currentAddress/ns2:country), 
             data($currentAddress/ns2:postalOrZipCode) 
            ) 
           }</CurrentAddress> 
         } 
        </Client> 
      } 
     </ns3:TemplateUpdateClient-WrkFrm> 
}; 

declare variable $updateClient1 as element(ns0:updateClient) external; 

xf:WCtest($updateClient1) 

は、私はそれを実行しようとしていたデータのサンプルです:ここで

<?xml version="1.0"?> 
<updateClient xmlns="http://www.websitename.com/claims/client/UpdateClient.xsd" xmlns:cus="http://www.websitename.com/common/customDataTypes.xsd"> 
    <Client> 
    <claimNumber>00000</claimNumber> 
    <SIN>000000000</SIN> 
    <fullName> 
     <firstName>First</firstName> 
     <middleName>Middle</middleName> 
     <lastName>Last</lastName> 
    </fullName> 
    <gender>male</gender> 
    <maritalStatus>married</maritalStatus> 
    <currentAddress> 
     <cus:line1>line1</cus:line1> 
     <cus:line2/> 
     <cus:line3/> 
     <cus:city>city</cus:city> 
     <cus:provinceOrState>province</cus:provinceOrState> 
     <cus:postalOrZipCode>H0H 0H0</cus:postalOrZipCode> 
     <cus:country>CA</cus:country> 
    </currentAddress> 
    </Client> 
</updateClient> 

が働いている変換です:

(:: pragma bea:global-element-parameter parameter="$workerAppeal1" element="ns0:workerAppeal" location="../../xsd/claims/worker/appeal/WorkerAppeal.xsd" ::) 
(:: pragma bea:global-element-return element="ns2:TemplateWorkerAppeal-WrkFrm" location="../../xsd/claims/templates/ais/WorkerAppeal.xsd" ::) 

declare namespace ns2 = "http://www.website.com/document/production/template/templateworkerappeal"; 
declare namespace ns1 = "http://www.website.com/document/production/common/customDataTypes"; 
declare namespace ns3 = "http://www.website.com/document/production/templatebase"; 
declare namespace ns0 = "http://www.website.com/claims/worker/appeal/WorkerAppeal.xsd"; 
declare namespace xf = "http://tempuri.org/DocumentSubmissionConversionOSB/XQuery/AIS/AIStest/"; 


(:~ 
: This function converts a set of strings describing 
: an address into the new address format 
: 
: @param $recipient the addressee 
: @param $line1 address Line#1 
: @param $line2 address Line#2 
: @param $lnie3 address Line#3 
: @param $city the city 
: @param $provinceOrState the province (if CA) or state (if US) 
: @param $country the country (CA, US, or something else) 
: @param $postalOrZIP the postal code (if CA or other) or zip code (if US) 
: @return either a <CanadanAddress>, a <USAddress>, or an <InternationalAddress> depending on the country 
:) 
declare function local:to-address(
    $recipient as xs:string, 
    $line1 as xs:string, 
    $line2 as xs:string, 
    $line3 as xs:string, 
    $city as xs:string, 
    $provinceOrState as xs:string, 
    $country as xs:string, 
    $postalOrZIP as xs:string 
) 
as element() { 
    if (fn:upper-case($country) = 'CA') then 
     <CanadianAddress> 
      <City>{ $city }</City> 
      <Country>{ $country }</Country> 
      <PostalCode>{ $postalOrZIP }</PostalCode> 
      <Province>{ $provinceOrState }</Province> 
      <Recipient>{ $recipient }</Recipient> 
      <StreetAddress>{ $line1 }</StreetAddress> 
      <StreetAddress>{ $line2 }</StreetAddress> 
      <StreetAddress>{ $line3 }</StreetAddress> 
      <StreetAddress/> 
     </CanadianAddress> 
    else 
     if (fn:upper-case($country) = 'US') then 
      <USAddress> 
       <City>{ $city }</City> 
       <Country>{ $country }</Country> 
       <ZipCode>{ $postalOrZIP }</ZipCode> 
       <State>{ $provinceOrState }</State> 
       <Recipient>{ $recipient }</Recipient> 
       <StreetAddress>{ $line1 }</StreetAddress> 
       <StreetAddress>{ $line2 }</StreetAddress> 
       <StreetAddress>{ $line3 }</StreetAddress> 
      </USAddress>   
     else   
      <InternationalAddress> 
       <City>{ $city }</City> 
       <Country>{ $country }</Country> 
       <PostalCode>{ $postalOrZIP }</PostalCode> 
       <Recipient>{ $recipient }</Recipient> 
       <StreetAddress>{ $line1 }</StreetAddress> 
       <StreetAddress>{ $line2 }</StreetAddress> 
       <StreetAddress>{ $line3 }</StreetAddress> 
      </InternationalAddress> 
     (:endif:) 
    (:endif:) 
}; 

declare function xf:AIStest($workerAppeal1 as element(ns0:workerAppeal)) 
    as element(ns2:TemplateWorkerAppeal-WrkFrm) { 
     <ns2:TemplateWorkerAppeal-WrkFrm> 
      <AppealDate>{ data($workerAppeal1/ns0:appealDate) }</AppealDate> 
      <DecisionAppealled>{ data($workerAppeal1/ns0:decisionAppealled) }</DecisionAppealled> 
      <DecisionWrong>{ data($workerAppeal1/ns0:decisionWrong) }</DecisionWrong> 
      <Expectations>{ data($workerAppeal1/ns0:expectations) }</Expectations> 
      { 
       let $Appellant := $workerAppeal1/ns0:Appellant 
       return 
        <Appellant> 
         { 
          let $claimantName := $Appellant/ns0:claimantName 
          return 
           <ClaimantName> 
            <FirstName>{ data($claimantName/ns0:firstName) }</FirstName> 
            <LastName>{ data($claimantName/ns0:lastName) }</LastName> 
           </ClaimantName> 
         } 
         <ClaimNumber>{ data($Appellant/ns0:claimNumber) }</ClaimNumber> 
         <AreYouTheClaimant>{ data($Appellant/ns0:areYouTheClaimant) }</AreYouTheClaimant> 
        </Appellant> 
      } 
      { 
       let $Representative := $workerAppeal1/ns0:Representative 
       return 
        <Representative> 
         { 
          let $phoneNumber := $Representative/ns0:phoneNumber 
          return 
           <Phone> 
            <AreaCode>{ data($phoneNumber/ns0:areaCode) }</AreaCode> 
            <Number>{ data($phoneNumber/ns0:numeric) }</Number> 
           </Phone> 
         } 
         <RelationshipToAppellant>{ data($Representative/ns0:relationshiptoAppellant) }</RelationshipToAppellant> 
         { 
          let $representativeAddress := $Representative/ns0:representativeAddress 
          return 
           <RepresentativeAddress>{ 
            local:to-address(
             concat(
              data($Representative/ns0:representativeName/ns0:firstName), 
              ' ', 
              data($Representative/ns0:representativeName/ns0:lastName) 
             ), 
             data($representativeAddress/ns0:addressLine1), 
             data($representativeAddress/ns0:addressLine2), 
             data($representativeAddress/ns0:addressLine3), 
             data($representativeAddress/ns0:city), 
             data($representativeAddress/ns0:province), 
             data($representativeAddress/ns0:country), 
             data($representativeAddress/ns0:postalCode) 
            ) 
           }</RepresentativeAddress> 
         } 
         { 
          let $representativeName := $Representative/ns0:representativeName 
          return 
           <RepresentativeName> 
            <FirstName>{ data($representativeName/ns0:firstName) }</FirstName> 
            <LastName>{ data($representativeName/ns0:lastName) }</LastName> 
           </RepresentativeName> 
         } 
         <EmailAddress>{ data($Representative/ns0:emailAddress) }</EmailAddress> 
        </Representative> 
      } 
     </ns2:TemplateWorkerAppeal-WrkFrm> 
}; 

declare variable $workerAppeal1 as element(ns0:workerAppeal) external; 

xf:AIStest($workerAppeal1) 

そして、ここではそのためのサンプルデータです:

<?xml version="1.0"?> 
<workerAppeal xmlns="http://www.websitename.com/claims/worker/appeal/WorkerAppeal.xsd"> 
    <appealDate>2011-02-03-11:00</appealDate> 
    <Appellant> 
    <claimNumber>00000</claimNumber> 
    <claimantName> 
     <firstName>First</firstName> 
     <lastName>Last</lastName> 
    </claimantName> 
    <areYouTheClaimant>true</areYouTheClaimant> 
    </Appellant> 
    <Representative> 
    <representativeName> 
     <firstName/> 
     <lastName/> 
    </representativeName> 
    <relationshiptoAppellant/> 
    <representativeAddress> 
     <addressLine1/> 
     <addressLine2/> 
     <addressLine3/> 
     <city>city</city> 
     <province>province</province> 
     <postalCode>H0H 0H0</postalCode> 
     <country>CA</country> 
    </representativeAddress> 
    <phoneNumber> 
     <areaCode>111</areaCode> 
     <numeric>1111111</numeric> 
    </phoneNumber> 
    <emailAddress>[email protected]</emailAddress> 
    </Representative> 
    <decisionAppealled>decisionAppealled</decisionAppealled> 
    <decisionWrong>decisionWrong</decisionWrong> 
    <expectations>expectations</expectations> 
</workerAppeal> 

変換ファイルは、主にカスタムアドレス機能を除いてマッパーによって自動生成されます。 2つの変換の間に見られる唯一の大きな違いは、サンプルファイル内のこれらの行です。作業用のファイルには名前空間が1つしかなく、エラーのあるファイルには2つしかありません。

<workerAppeal xmlns="http://www.website.com/claims/worker/appeal/WorkerAppeal.xsd"><!--Working--> 
<updateClient xmlns="http://www.website.com/claims/client/UpdateClient.xsd" xmlns:cus="http://www.website.com/common/customDataTypes.xsd"><!--Gives error--> 

XQueryは依然として私にとってかなり外国のものであり、これがナットを運転しているので、助けがあれば大いに感謝します。 (はい、コードは匿名化されていますが、URLは実際にwww.website.comではありません)。

ありがとうございます!この宣言から

答えて

0

declare namespace 
     ns0 = "http://www.websitename.com/claims/client/UpdateClient"; 

declare function xf:WCtest($updateClient1 as element(ns0:updateClient)) 

declare variable $updateClient1 as element(ns0:updateClient) external; 

それはxf:WCtest()機能と$updateClient1外部変数(パラメータ){http://www.websitename.com/claims/client/UpdateClient}updateClient要素を期待していることを意味するが、あなたの入力ソースは、{http://www.websitename.com/claims/client/UpdateClient.xsd}updateClientを持っています。しかし、もちろん、私はERR

http://www.w3.org/TR/2004/WD-xquery-20040723/#ERRXP0006から

...あなたは、パラメータとして渡しているのか分からない:XP0006
評価フェーズでは、それはtype error 場合値が の一致するルールと一致する必要のあるタイプと一致しません。 2.4.4 SequenceType Matching

+0

Whoohoo!私は名前空間宣言の最後に.xsdを追加しようとしましたが、それは問題を解決したようです。私は彼らが私のために生成されて以来、それらに触れることについて考えなかった。ありがとう、トン! – Jason

+0

@Jason:ようこそ! –

+0

[Nithi](http://stackoverflow.com/users/4353240/nithi)は言った: '私は同じエラーが発生しています。 JAson、名前空間の後にxsdの名前をどこに追加したか教えてください。送信した入力XMLにありますか?' –