XSLT transformation to read xml element and value and convert xml data into name value pair

房东的猫 提交于 2020-04-18 05:35:52

问题


Need below help to adjust the xslt so that if there is repeating multioccurance node example "SalesQuoteParty" then :

  1. Only Produce output name value pair if SalesQuoteParty-RoleCode = 39 or 1001 (Need help how to filter party data based on Role Code)
  2. Concatenate the value of element RoleCodeText to the name, for example, current output - SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.RoleCodeText becomes - Owner.SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.RoleCodeText

Input XML data
<SalesQuoteCollection>
	<SalesQuote>
		<CurrencyCode>GBP</CurrencyCode>
		<TaxAmount>0.000000</TaxAmount>
		<PriceDateTime>2020-03-17T14:52:55.439</PriceDateTime>
		<DocumentLanguageCode>EN</DocumentLanguageCode>
		<SalesQuoteParty>
			<SalesQuoteParty>
				<PartyName>Porter LLC</PartyName>
				<PartyID>1001</PartyID>
				<RoleCode>1001</RoleCode>
				<RoleCodeText>Account</RoleCodeText>
				<FirstLineName>Porter LLC</FirstLineName>
			</SalesQuoteParty>
			<SalesQuoteParty>
				<PartyName>Manish Admin</PartyName>
				<PartyID>8000000705</PartyID>
				<RoleCode>39</RoleCode>
				<RoleCodeText>Owner</RoleCodeText>
				<FirstLineName>Mr. Manish Admin</FirstLineName>
			</SalesQuoteParty>
		</SalesQuoteParty>
		<ProcessingTypeCode>AG</ProcessingTypeCode>
	</SalesQuote>
</SalesQuoteCollection>

<?xml version="1.0" encoding="UTF-8"?>

Current Output using xslt
<group>
	<Name>SalesQuoteCollection.SalesQuote.CurrencyCode</Name>
	<Value>GBP</Value>
	<Name>SalesQuoteCollection.SalesQuote.TaxAmount</Name>
	<Value>0.000000</Value>
	<Name>SalesQuoteCollection.SalesQuote.PriceDateTime</Name>
	<Value>2020-03-17T14:52:55.439</Value>
	<Name>SalesQuoteCollection.SalesQuote.DocumentLanguageCode</Name>
	<Value>EN</Value>
	<Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.PartyName</Name>
	<Value>Porter LLC</Value>
	<Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.PartyID</Name>
	<Value>1001</Value>
	<Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.RoleCode</Name>
	<Value>1001</Value>
	<Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.RoleCodeText</Name>
	<Value>Account</Value>
	<Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.FirstLineName</Name>
	<Value>Porter LLC</Value>
	<Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.PartyName</Name>
	<Value>Manish Admin</Value>
	<Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.PartyID</Name>
	<Value>8000000705</Value>
	<Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.RoleCode</Name>
	<Value>39</Value>
	<Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.RoleCodeText</Name>
	<Value>Owner</Value>
	<Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.FirstLineName</Name>
	<Value>Mr. Manish Admin</Value>
	<Name>SalesQuoteCollection.SalesQuote.ProcessingTypeCode</Name>
	<Value>AG</Value>
</group>

Need below help to adjust the xslt so that if there is repeating multioccurance node example "SalesQuoteParty" then :

1. Only Produce output name value pair if SalesQuoteParty-RoleCode = 39 or 1001 (Need help how to filter party data based on Role Code)
2. Concatenate the value of element RoleCodeText to the name, for example, current output - <Name>SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.RoleCodeText</Name>
becomes - <Name>Owner.SalesQuoteCollection.SalesQuote.SalesQuoteParty.SalesQuoteParty.RoleCodeText</Name>

来源:https://stackoverflow.com/questions/60983009/xslt-transformation-to-read-xml-element-and-value-and-convert-xml-data-into-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!