XSLT-преобразование для преобразования xml данных в пару имя-значение - PullRequest
0 голосов
/ 01 апреля 2020

Текущий код xslt отображает имя элемента xml как имя и значение xml в значение цели xml. Мое требование состоит в том, чтобы настроить функцию так, чтобы я мог передавать имя узла так, чтобы переводились только определенные c данные узла.


XSLT-код

<xsl:function name="func:fqname">
    <xsl:param name="elements" as="element()*"/>
    <xsl:variable name="names" as="xs:string*">
        <xsl:for-each select="$elements">
            <xsl:sequence select="local-name(.)"/>
        </xsl:for-each>
    </xsl:variable>
    <xsl:value-of select="string-join($names, '.')"/>
</xsl:function>

<xsl:template match="/">
    <group>
        <xsl:for-each select="//*[text() and not(descendant::*)]">
            <Name><xsl:value-of select="func:fqname(ancestor-or-self::*)"/></Name>
            <Value><xsl:value-of select="."/></Value>
        </xsl:for-each>
    </group>
</xsl:template>

Входящий XML

<SalesQuoteCollection>
<SalesQuote>
  <NetWeightUnitCodeText></NetWeightUnitCodeText>
  <DivisionCodeText></DivisionCodeText>
  <ApprovalStatusCode>1</ApprovalStatusCode>
  <DateTime>2020-03-17T14:52:55.439</DateTime>
  <PricingProcedureCode>PPSTD1</PricingProcedureCode>
  <CurrencyCode>GBP</CurrencyCode>
  <TaxAmount>0.000000</TaxAmount>
  <PriceDateTime>2020-03-17T14:52:55.439</PriceDateTime>
  <DocumentLanguageCode>EN</DocumentLanguageCode>
  <NetAmount>0.000000</NetAmount>
  <ProcessingTypeCodeText>Sales Quote</ProcessingTypeCodeText>
  <GrossAmountCurrencyCodeText>Pound Sterling</GrossAmountCurrencyCodeText>
  <ID>1486</ID>
  <GrossAmount>0.000000</GrossAmount>
  <NetAmountCurrencyCodeText>Pound Sterling</NetAmountCurrencyCodeText>
  <CreatedBy>Manish Admin</CreatedBy>
  <BuyerContactPartyName>Peter Gamoff</BuyerContactPartyName>
  <ProbabilityPercent>100.00</ProbabilityPercent>
  <PriceCalculationStatusCodeText>Calculated Successfully</PriceCalculationStatusCodeText>
  <PrimaryQuote>false</PrimaryQuote>
  <BuyerPartyID>1001</BuyerPartyID>
  <ExternalApprovalStatusCode></ExternalApprovalStatusCode>
  <EmployeeResponsiblePartyID>8000000705</EmployeeResponsiblePartyID>
  <ConfirmationExistenceIndicator>false</ConfirmationExistenceIndicator>
  <ExternalPriceCalculationStatusCodeText></ExternalPriceCalculationStatusCodeText>
  <BuyerID></BuyerID>
  <ETag>2020-03-25T12:42:22.963</ETag>
  <ValidFromDate>2020-03-17T00:00:00.000</ValidFromDate>
  <DistributionChannelCodeText>Direct sales</DistributionChannelCodeText>
  <NetWeightMeasure>0E-14</NetWeightMeasure>
  <ExternalPriceCalculationStatusCode></ExternalPriceCalculationStatusCode>
  <RequestExtData/>
  <VersionID>1</VersionID>
  <ConsistencyStatusCodeText>Consistent</ConsistencyStatusCodeText>
  <GrossAmountCurrencyCode>GBP</GrossAmountCurrencyCode>
  <DivisionCode></DivisionCode>
  <LastChangeIdentityUUID>00163e70-3a9e-1ee8-bffb-b27ec6eed2fd</LastChangeIdentityUUID>
  <VersionGroupID>1486</VersionGroupID>
  <GrossWeightUnitCode></GrossWeightUnitCode>
  <ExternalPricingProcedureCodeText></ExternalPricingProcedureCodeText>
  <CreationIdentityUUID>00163e70-3a9e-1ee8-bffb-b27ec6eed2fd</CreationIdentityUUID>
  <SalesGroupID></SalesGroupID>
  <TimeZoneCodeText>UTC+0</TimeZoneCodeText>
  <DeliveryPriorityCodeText>Normal</DeliveryPriorityCodeText>
  <ProductRecipientPartyName>Porter LLC</ProductRecipientPartyName>
  <DeliveryPriorityCode>3</DeliveryPriorityCode>
  <EntityLastChangedOn>2020-03-25T12:42:22.963</EntityLastChangedOn>
  <OrderReasonCode></OrderReasonCode>
  <SalesTerritoryName>United States</SalesTerritoryName>
  <SetAsWon/>
  <RequestExtFollowup>false</RequestExtFollowup>
  <ProductAvailabilityStatusCode>1</ProductAvailabilityStatusCode>
  <TimeZoneCode>UTC</TimeZoneCode>
  <CancellationReasonCode></CancellationReasonCode>
  <CreditWorthinessStatusCode></CreditWorthinessStatusCode>
  <Submit/>
  <LastChangeDateTime>2020-03-25T12:42:22.963</LastChangeDateTime>
  <SalesQuoteParty>
    <SalesQuoteParty>
      <StreetName>Centerstage</StreetName>
      <POBoxIndicator>false</POBoxIndicator>
      <Email>msingh@pros.com</Email>
      <RegionCode>MN</RegionCode>
      <ObjectID>00163E703A9E1EEA9A8BDF6B041812A4</ObjectID>
      <FloorID></FloorID>
      <PartyName>Porter LLC</PartyName>
      <RegionCodeText>Minnesota</RegionCodeText>
      <StreetPrefixName>1</StreetPrefixName>
      <ThirdLineName></ThirdLineName>
      <POBoxDeviatingRegionCode></POBoxDeviatingRegionCode>
      <PartyID>1001</PartyID>
      <POBoxPostalCodeText></POBoxPostalCodeText>
      <CorrespondenceLanguageCode>EN</CorrespondenceLanguageCode>
      <POBoxDeviatingRegionCodeText></POBoxDeviatingRegionCodeText>
      <ParentObjectID>00163E703A9E1EEA9A8BDF6B0416F2A4</ParentObjectID>
      <MainIndicator>true</MainIndicator>
      <SecondLineName></SecondLineName>
      <QuoteID>1486</QuoteID>
      <StreetSuffixName>2</StreetSuffixName>
      <CityName>St. Paul</CityName>
      <PartyContactPartyID>1000476</PartyContactPartyID>
      <Web></Web>
      <ETag>2020-03-25T12:42:22.963</ETag>
      <FourthLineName></FourthLineName>
      <BuildingID></BuildingID>
      <POBoxDeviatingCountryCodeText></POBoxDeviatingCountryCodeText>
      <CareOfName></CareOfName>
      <POBoxDeviatingCityName></POBoxDeviatingCityName>
      <AdditionalStreetSuffixName></AdditionalStreetSuffixName>
      <CountryCodeText>United States</CountryCodeText>
      <HouseID>5</HouseID>
      <AdditionalCityName></AdditionalCityName>
      <RoleCode>1001</RoleCode>
      <StreetPostalCode>55144</StreetPostalCode>
      <POBoxDeviatingCountryCode></POBoxDeviatingCountryCode>
      <CompanyPostalCodeText></CompanyPostalCodeText>
      <PartyContactPartyName>Peter Gamoff</PartyContactPartyName>
      <StreetPostalCodeText></StreetPostalCodeText>
      <Phone>+1 (651) 733-2220</Phone>
      <RoleCodeText>Account</RoleCodeText>
      <CountryCode>US</CountryCode>
      <CorrespondenceLanguageCodeText>English</CorrespondenceLanguageCodeText>
      <PreferredCommunicationMediumTypeCodeText></PreferredCommunicationMediumTypeCodeText>
      <PreferredCommunicationMediumTypeCode></PreferredCommunicationMediumTypeCode>
      <RoomID></RoomID>
      <Mobile></Mobile>
      <CountyName></CountyName>
      <POBoxID>456765</POBoxID>
      <AdditionalStreetPrefixName></AdditionalStreetPrefixName>
      <DistrictName></DistrictName>
      <POBoxPostalCode></POBoxPostalCode>
      <FirstLineName>Porter LLC</FirstLineName>
      <CompanyPostalCode></CompanyPostalCode>
      <Fax>+1 (651) 733-1111</Fax>
    </SalesQuoteParty>
    <SalesQuoteParty>
      <StreetName></StreetName>
      <POBoxIndicator>false</POBoxIndicator>
      <Email></Email>
      <RegionCode></RegionCode>
      <ObjectID>00163E703A9E1EEA9A8BDF6B041972A4</ObjectID>
      <FloorID></FloorID>
      <PartyName>Manish Admin</PartyName>
      <RegionCodeText></RegionCodeText>
      <StreetPrefixName></StreetPrefixName>
      <ThirdLineName></ThirdLineName>
      <POBoxDeviatingRegionCode></POBoxDeviatingRegionCode>
      <PartyID>8000000705</PartyID>
      <POBoxPostalCodeText></POBoxPostalCodeText>
      <CorrespondenceLanguageCode></CorrespondenceLanguageCode>
      <POBoxDeviatingRegionCodeText></POBoxDeviatingRegionCodeText>
      <ParentObjectID>00163E703A9E1EEA9A8BDF6B0416F2A4</ParentObjectID>
      <MainIndicator>true</MainIndicator>
      <SecondLineName></SecondLineName>
      <QuoteID>1486</QuoteID>
      <StreetSuffixName></StreetSuffixName>
      <CityName></CityName>
      <PartyContactPartyID></PartyContactPartyID>
      <Web></Web>
      <ETag>2020-03-25T12:42:22.963</ETag>
      <FourthLineName></FourthLineName>
      <BuildingID></BuildingID>
      <POBoxDeviatingCountryCodeText></POBoxDeviatingCountryCodeText>
      <CareOfName></CareOfName>
      <POBoxDeviatingCityName></POBoxDeviatingCityName>
      <AdditionalStreetSuffixName></AdditionalStreetSuffixName>
      <CountryCodeText></CountryCodeText>
      <HouseID></HouseID>
      <AdditionalCityName></AdditionalCityName>
      <RoleCode>39</RoleCode>
      <StreetPostalCode></StreetPostalCode>
      <POBoxDeviatingCountryCode></POBoxDeviatingCountryCode>
      <CompanyPostalCodeText></CompanyPostalCodeText>
      <PartyContactPartyName></PartyContactPartyName>
      <StreetPostalCodeText></StreetPostalCodeText>
      <Phone></Phone>
      <RoleCodeText>Owner</RoleCodeText>
      <CountryCode></CountryCode>
      <CorrespondenceLanguageCodeText></CorrespondenceLanguageCodeText>
      <PreferredCommunicationMediumTypeCodeText></PreferredCommunicationMediumTypeCodeText>
      <PreferredCommunicationMediumTypeCode></PreferredCommunicationMediumTypeCode>
      <RoomID></RoomID>
      <Mobile></Mobile>
      <CountyName></CountyName>
      <POBoxID></POBoxID>
      <AdditionalStreetPrefixName></AdditionalStreetPrefixName>
      <DistrictName></DistrictName>
      <POBoxPostalCode></POBoxPostalCode>
      <FirstLineName>Mr. Manish Admin</FirstLineName>
      <CompanyPostalCode></CompanyPostalCode>
      <Fax></Fax>
    </SalesQuoteParty>
      <StreetName>Tottenham Court Road</StreetName>
      <POBoxIndicator>false</POBoxIndicator>
      <Email>cod.servicerequest@my306029.mail.crm.ondemand.com</Email>
      <RegionCode></RegionCode>
      <ObjectID>00163E703A9E1EEA9A8BE301886C3330</ObjectID>
      <FloorID></FloorID>
      <PartyName>Company UK</PartyName>
      <RegionCodeText></RegionCodeText>
      <StreetPrefixName></StreetPrefixName>
      <ThirdLineName></ThirdLineName>
      <POBoxDeviatingRegionCode></POBoxDeviatingRegionCode>
      <PartyID>COMPANYUK</PartyID>
      <POBoxPostalCodeText></POBoxPostalCodeText>
      <CorrespondenceLanguageCode></CorrespondenceLanguageCode>
      <POBoxDeviatingRegionCodeText></POBoxDeviatingRegionCodeText>
      <ParentObjectID>00163E703A9E1EEA9A8BDF6B0416F2A4</ParentObjectID>
      <MainIndicator>true</MainIndicator>
      <SecondLineName></SecondLineName>
      <QuoteID>1486</QuoteID>
      <StreetSuffixName></StreetSuffixName>
      <CityName>London</CityName>
      <PartyContactPartyID></PartyContactPartyID>
      <Web>http://www.sap.com/customerondemand</Web>
      <ETag>2020-03-25T12:42:22.963</ETag>
      <FourthLineName></FourthLineName>
      <BuildingID></BuildingID>
      <POBoxDeviatingCountryCodeText></POBoxDeviatingCountryCodeText>
      <CareOfName></CareOfName>
      <POBoxDeviatingCityName></POBoxDeviatingCityName>
      <AdditionalStreetSuffixName></AdditionalStreetSuffixName>
      <CountryCodeText>United Kingdom</CountryCodeText>
      <HouseID>175</HouseID>
      <AdditionalCityName></AdditionalCityName>
      <RoleCode>2</RoleCode>
      <StreetPostalCode>W1T 7NU</StreetPostalCode>
      <POBoxDeviatingCountryCode></POBoxDeviatingCountryCode>
      <CompanyPostalCodeText></CompanyPostalCodeText>
      <PartyContactPartyName></PartyContactPartyName>
      <StreetPostalCodeText></StreetPostalCodeText>
      <Phone>+44 2036203883</Phone>
      <RoleCodeText>Seller</RoleCodeText>
      <CountryCode>GB</CountryCode>
      <CorrespondenceLanguageCodeText></CorrespondenceLanguageCodeText>
      <PreferredCommunicationMediumTypeCodeText></PreferredCommunicationMediumTypeCodeText>
      <PreferredCommunicationMediumTypeCode></PreferredCommunicationMediumTypeCode>
      <RoomID></RoomID>
      <Mobile></Mobile>
      <CountyName></CountyName>
      <POBoxID></POBoxID>
      <AdditionalStreetPrefixName></AdditionalStreetPrefixName>
      <DistrictName></DistrictName>
      <POBoxPostalCode></POBoxPostalCode>
      <FirstLineName>Company UK</FirstLineName>
      <CompanyPostalCode></CompanyPostalCode>
      <Fax>+44 2036203885</Fax>
    </SalesQuoteParty>
  </SalesQuoteParty>
  <ProcessingTypeCode>AG</ProcessingTypeCode>
  <LastChangedBy>Manish Admin</LastChangedBy>
  <GrossWeightMeasure>0E-14</GrossWeightMeasure>
  <CashDiscountTermsCode>1002</CashDiscountTermsCode>
  <ObjectID>00163E703A9E1EEA9A8BDF6B0416F2A4</ObjectID>
  <IncotermsTransferLocationName></IncotermsTransferLocationName>
  <VolumeUnitCode></VolumeUnitCode>
  <BuyerContactPartyID>1000476</BuyerContactPartyID>
  <SalesOfficeName></SalesOfficeName>
  <Name>Multiple ODATA Calls 111</Name>
  <TaxAmountCurrencyCodeText>Pound Sterling</TaxAmountCurrencyCodeText>
  <Name3></Name3>
  <Name4></Name4>
  <NetAmountCurrencyCode>GBP</NetAmountCurrencyCode>
  <Name8></Name8>
  <Name9></Name9>
  <LifeCycleStatusCode>1</LifeCycleStatusCode>
  <ReplicationProcessingStatusCodeText></ReplicationProcessingStatusCodeText>
  <ApprovalStatusCodeText>Not Started</ApprovalStatusCodeText>
  <PricingProcedureCodeText>Standard Procedure</PricingProcedureCodeText>
  <ProductRecipientPartyID>1001</ProductRecipientPartyID>
  <TaxAmountCurrencyCode>GBP</TaxAmountCurrencyCode>
  <Name1></Name1>
  <Name2></Name2>
  <ValidToDate>2020-03-20T00:00:00.000</ValidToDate>
  <OrderReasonCodeText></OrderReasonCodeText>
  <VolumeUnitCodeText></VolumeUnitCodeText>
  <ProductAvailabilityStatusCodeText>Confirmation Pending</ProductAvailabilityStatusCodeText>
  <Name11></Name11>
  <SalesOrganisationID>4000</SalesOrganisationID>
  <Name10></Name10>
  <SalesUnitPartyName>UK Service &amp; Social</SalesUnitPartyName>
  <ConsistencyStatusCode>3</ConsistencyStatusCode>
  <ExternalPricingProcedureCode></ExternalPricingProcedureCode>
  <Name13></Name13>
  <Name12></Name12>
  <OrderingStatusCode>1</OrderingStatusCode>
  <GrossWeightUnitCodeText></GrossWeightUnitCodeText>
  <External>false</External>
  <CancellationReasonCodeText></CancellationReasonCodeText>
  <ResultStatusCodeText>Not Relevant</ResultStatusCodeText>
  <CurrencyCodeText>Pound Sterling</CurrencyCodeText>
  <RequestedFulfillmentStartDateTime>2020-03-19T00:00:00Z</RequestedFulfillmentStartDateTime>
  <DocumentLanguageCodeText>English</DocumentLanguageCodeText>
  <IncotermsClassificationCodeText></IncotermsClassificationCodeText>
  <ReplicationProcessingStatusCode></ReplicationProcessingStatusCode>
  <PROS_CorrelationID_SDK>00163E703A9E1EEA9A8BDF6B0416F2A4|643075cc-67fb-436d-85e4-fcf283a2407a</PROS_CorrelationID_SDK>
  <BuyerPartyName>Porter LLC</BuyerPartyName>
  <LifeCycleStatusCodeText>Open</LifeCycleStatusCodeText>
  <SynchronizationStatusPROS_SDK></SynchronizationStatusPROS_SDK>
  <CancellationStatusCodeText>Not Canceled</CancellationStatusCodeText>
  <SalesOfficeID></SalesOfficeID>
  <SalesUnitPartyID>UK3200</SalesUnitPartyID>
  <SalesGroupName></SalesGroupName>
  <SalesTerritoryID>2</SalesTerritoryID>
  <CancellationStatusCode>1</CancellationStatusCode>
  <IncotermsClassificationCode></IncotermsClassificationCode>
  <EmployeeResponsiblePartyName>Manish Admin</EmployeeResponsiblePartyName>
  <NetWeightUnitCode></NetWeightUnitCode>
  <SynchronizationStatusPROS_SDKText></SynchronizationStatusPROS_SDKText>
  <SetAsLost>false</SetAsLost>
  <ExternalApprovalStatusCodeText></ExternalApprovalStatusCodeText>
  <ResultStatusCode>1</ResultStatusCode>
  <OrderingStatusCodeText>Not Started</OrderingStatusCodeText>
  <PriceCalculationStatusCode>2</PriceCalculationStatusCode>
  <CreationDateTime>2020-03-17T14:53:49.078</CreationDateTime>
  <VolumeMeasure>0E-14</VolumeMeasure>
  <CreditWorthinessStatusCodeText></CreditWorthinessStatusCodeText>
  <SalesOrganisationName>UK Sales &amp; Service</SalesOrganisationName>
  <DistributionChannelCode>01</DistributionChannelCode>
  <CPQ_Quote_ID_SDK>643075cc-67fb-436d-85e4-fcf283a2407a</CPQ_Quote_ID_SDK>
  <MainDiscount>0E-14</MainDiscount>
  <UpdateOpportunity/>
  <CashDiscountTermsCodeText>20 days net</CashDiscountTermsCodeText>
</SalesQuote>


Мне необходимо отфильтровать узел SalesQuoteParty с помощью xslt

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...