XQuery 转换中的 XP0006 错误

发布于 2024-10-16 06:48:00 字数 17439 浏览 3 评论 0原文

我在尝试运行 XQuery 转换(OSB 的 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 文件包含多个命名空间。在仅具有一个命名空间的 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>

转换文件主要是由映射器(自定义地址函数除外)。 我在这两种转换之间看到的唯一主要区别是示例文件中的这些行 - 工作的转换只有一个命名空间,而出现错误的转换有两个。

<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。希望这不会引起任何问题)

提前致谢!

I am getting an XP0006 error when trying to run an XQuery transformation (OSB's XQuery implementation if that makes any difference) and I am having a hard time resolving it.

The error given is

 <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> 

As far as I can tell the source of this error is the fact that my source XML files contain multiple namespaces. A separate transformation that is running on XML files with only one namespace is running fine.

Here is the transformation that is giving me trouble:

(:: 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)

Here is a sample of the data I am trying to run through it:

<?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>

Here is a transformation that is working:

(:: 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)

And here is sample data for it:

<?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>

The transformation files are mainly auto-generated by the mapper except for the custom address function.
The only major difference I can see between the two transformations is these lines in the sample files - the working one has only one namespace, and the one with the error has two.

<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-->

Any help would by hugely appreciated, because XQuery is still a fairly foreign thing to me and this is driving me nuts. (Yes, the code has been anonymized somewhat - the URLs aren't really www.website.com for example. Hopefully this hasn't caused any issues)

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

朱染 2024-10-23 06:48:00

从这个声明来看:

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。但是,当然,我不知道您作为参数传递的内容...

来自 http://www.w3.org/TR/2004/WD-xquery-20040723/#ERRXP0006

错误:XP0006
在评估阶段,这是一个类型错误 如果一个
值与所需类型不匹配
由匹配规则指定
2.4.4 SequenceType 匹配

From this declarations:

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;

It means that xf:WCtest() function and $updateClient1 external variable (parameter) expect {http://www.websitename.com/claims/client/UpdateClient}updateClient elements, but your input source has a {http://www.websitename.com/claims/client/UpdateClient.xsd}updateClient. But, of course, I don't know what you are passing as parameter...

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

err:XP0006
During the evaluation phase, it is a type error if a
value does not match a required type
as specified by the matching rules in
2.4.4 SequenceType Matching.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文