Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2016, 10:08 AM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default How do I output 2 parent nodes with their children?

I am using a template to output NotificationEvent. My xml has 2 NotificationEvents. The problem is that I am not getting correct output

Expected output
Code:
<IntegrationConditions>
	<IntegrationCondition Word="CASEDETAIL" Description="CaseDetail/Security">
		<NotificationEvent notificationType="CaseDetailsNotification" elementState="Existing" elementName="Case" elementKey="14886023">CaseTitleModified</NotificationEvent>
	</IntegrationCondition>
	<IntegrationCondition Word="SUBPARTY" Description="SubjectParty">
		<NotificationEvent notificationType="SubjectPartyNotification" elementState="Existing" elementName="CaseRespondent" elementKey="18118912">SubjectPartyNameAdded</NotificationEvent>
	</IntegrationCondition>
</IntegrationConditions>
xml document

Code:
<Integration>
	<ControlPoint>SAVE-FAM-CASE</ControlPoint>
	<Case ID="14886023" Op="E" xmlns:user="http://tylertechnologies.com">
		<CaseCategory>FAM</CaseCategory>
		<CaseType Word="DMA">Domestic Abuse</CaseType>
		<BaseCaseType>Civil Domestic Violence</BaseCaseType>
		<CaseTitle Op="E">In the Matter</CaseTitle>
		<CaseNumber>370</CaseNumber>


		<CaseParty Op="E" ID="18118912" InternalCasePartyID="1649118185" InternalPartyID="1617896624">
			<Connection Word="RSP" BaseConnection="DF" ID="44925838" InternalCasePartyConnectionID="1651131186">
				<Description>Respondent</Description>
			</Connection>
			<CasePartyName ID="12124296" InternalNameID="1618924116">
				<NameFirst>SILLY</NameFirst>
				<NameLast>SOLLY</NameLast>
				<FormattedName>SOLLY, SILLY</FormattedName>
			</CasePartyName>
			<CasePartyName Op="A" Current="true" ID="12124639" InternalNameID="1618924395">
				<CasePartyNameType Op="A" Word=""/>
				<NameMiddle>Soo</NameMiddle>
				<FormattedName>Solly, Silly Soo</FormattedName>
			</CasePartyName>
		</CaseParty>

	<IntegrationConditions>
		<IntegrationCondition Word="CASEDETAIL" Description="CaseDetail/Security">
			<NotificationEvent notificationType="CaseDetailsNotification" elementState="Existing" elementName="Case" elementKey="14886023">CaseTitleModified</NotificationEvent>
		</IntegrationCondition>
		<IntegrationCondition Word="SUBPARTY" Description="SubjectParty">
			<NotificationEvent notificationType="SubjectPartyNotification" elementState="Existing" elementName="CaseRespondent" elementKey="18118912">SubjectPartyNameAdded</NotificationEvent>
		</IntegrationCondition>
	</IntegrationConditions>
</Integration>
My xslt code with template
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet>
	<xsl:template name="CaseDetailsNotification">
		<xsl:if test="Integration/ControlPoint='SAVE-FAM-CASE'">
			<xsl:if test="Integration/Case/CaseType/@Word='DMA'">
				<xsl:for-each select="Integration/Case[@Op='E']">/Integration/IntegrationConditions/IntegrationCondition[2]/NotificationEvent/@notificationType
				<NotificationEvent notificationType="CaseDetailsNotification">
						<xsl:attribute name="elementState"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementState"/></xsl:attribute>
						<xsl:attribute name="elementName"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementName"/></xsl:attribute>
						<xsl:attribute name="elementKey"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementKey"/></xsl:attribute>
						<xsl:choose>
							<xsl:when test="/Integration/Case/@Op='E'">CaseTitleModified</xsl:when>
						</xsl:choose>
					</NotificationEvent>
				</xsl:for-each>
			</xsl:if>
		</xsl:if>
		<!-- Check PartyName change-->
		<xsl:if test="Integration/Case/CaseType/@Word='DMA'">
			<xsl:for-each select="/Integration/Case/CaseParty[@Op='E']">
				<NotificationEvent notificationType="CaseDetailsNotification">
					<xsl:attribute name="elementState"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementState"/></xsl:attribute>
					<xsl:attribute name="elementName"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementName"/></xsl:attribute>
					<xsl:attribute name="elementKey"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementKey"/></xsl:attribute>
					<xsl:choose>
						<xsl:when test="/Integration/Case/CaseParty/@Op='E'">SubjectPartyNameAdded</xsl:when>
					</xsl:choose>
				</NotificationEvent>
			</xsl:for-each>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
 
Old October 6th, 2016, 11:20 AM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default I no longer need help with this one

Needs no help for this





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT Exclude Parent and children from XML BobSSC XSLT 2 March 16th, 2011 02:46 PM
Copy parent node and not its children bonekrusher XSLT 4 August 29th, 2007 08:44 AM
help with nodes/children bmmayer XML 0 July 13th, 2007 05:04 PM
having trouble with nodes/children bmmayer XSLT 3 July 13th, 2007 04:52 PM
get all children nodes maratg XSLT 4 November 7th, 2003 02:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.