View Single Post
 
Old October 17th, 2013, 03:58 AM
SRTrice SRTrice is offline
Registered User
Points: 23, Level: 1
Points: 23, Level: 1 Points: 23, Level: 1 Points: 23, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2013
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well here's the thing. the customer is asking for something that I do not have a case study for but perhaps more background will indeed help.
The product that will use this XSLT invokes specific events for employees to complete. They can have multiple events and each event has its own definition.
Event 1 name = event1
Event 2 name = event2

People involved with Event1 have labels called:
Event1 Coordinator
Event1 Manager

And the same for Event2 respectively.
I need to build logic in an XSLT that determines first the name of the event and then based on that specific name populate the correct corresponding people.

typically i only have to make small edits to existing xslt and we have tons of examples. but in this one case they are asking for customization that I can't figure out. I am a novice :) but learning.
I hope that helps.

here is my full xml:
Code:
<Candidate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://ns.hr-xml.org/2007-04-15"> 
<CandidateProfile> 
<PersonalData> 
		<PersonName> 
				<LegalName>test</LegalName> 
				<MiddleName></MiddleName> 
				<FamilyName>lane</FamilyName> 
		</PersonName> 
		<ContactMethod> 
				<Location>home</Location> 
				<Telephone> 
						<FormattedNumber>1234567</FormattedNumber> 
				</Telephone> 
				<InternetEmailAddress>test email</InternetEmailAddress > 
				<PostalAddress> 
						<CountryCode>United Kingdom</CountryCode> 
						<PostalCode>12345</PostalCode> 
						<Region></Region> 
						<Municipality></Municipality> 
						<DeliveryAddress> 
								<AddressLine>117 Pennypacker Road</AddressLine> 
								<StreetName></StreetName> 
						</DeliveryAddress> 
				</PostalAddress> 
		</ContactMethod> 
		<ContactMethod> 
				<Location>onPerson</Location> 
				<Telephone> 
						<FormattedNumber></FormattedNumber> 
				</Telephone> 
		</ContactMethod> 
		<BiologicalDescriptors> 
				<GenderCode></GenderCode> 
		</BiologicalDescriptors> 
</PersonalData> 
<EmploymentHistory> 
		<EmployerOrg> 
				<EmployerOrgName></EmployerOrgName> 
				<PositionHistory> 
						<Title></Title> 
						<OrgName> 
								<OrganizationName></OrganizationName> 
						</OrgName> 
						<StartDate> 
								<Year></Year> 
						</StartDate> 
						<EndDate> 
								<Year></Year> 
						</EndDate> 
				</PositionHistory> 
		</EmployerOrg> 
</EmploymentHistory> 
<EmploymentHistory> 
		<EmployerOrg> 
				<EmployerOrgName></EmployerOrgName> 
				<PositionHistory> 
						<Title></Title> 
						<OrgName> 
								<OrganizationName></OrganizationName> 
						</OrgName> 
						<StartDate> 
								<Year></Year> 
						</StartDate> 
						<EndDate> 
								<Year></Year> 
						</EndDate> 
				</PositionHistory> 
		</EmployerOrg> 
</EmploymentHistory> 
<EducationHistory> 
		<SchoolOrInstitution> 
				<SchoolName>University of Fun</SchoolName> 
				<Degree degreeType="ASME"> 
						<DegreeName>Mechanical</DegreeName> 
						<DegreeDate> 
								<Year>2013</Year> 
						</DegreeDate> 
						<DegreeMeasure> 
								<EducationalMeasure> 
										<MeasureSystem>GPA</MeasureSystem> 
										<MeasureValue> 
												<StringValue></StringValue> 
										</MeasureValue> 
								</EducationalMeasure> 
						</DegreeMeasure> 
				</Degree> 
		</SchoolOrInstitution> 
</EducationHistory> 
<EducationHistory> 
		<SchoolOrInstitution> 
				<SchoolName></SchoolName> 
				<Degree degreeType=""> 
						<DegreeName></DegreeName> 
						<DegreeDate> 
								<Year></Year> 
						</DegreeDate> 
						<DegreeMeasure> 
								<EducationalMeasure> 
										<MeasureSystem></MeasureSystem> 
										<MeasureValue> 
												<StringValue></StringValue> 
										</MeasureValue> 
								</EducationalMeasure> 
						</DegreeMeasure> 
				</Degree> 
		</SchoolOrInstitution> 
</EducationHistory> 
<EducationHistory> 
		<SchoolOrInstitution> 
				<SchoolName></SchoolName> 
				<Degree degreeType=""> 
						<DegreeName></DegreeName> 
						<DegreeDate> 
								<Year></Year> 
						</DegreeDate> 
						<DegreeMeasure> 
								<EducationalMeasure> 
										<MeasureSystem></MeasureSystem> 
										<MeasureValue> 
												<StringValue></StringValue> 
										</MeasureValue> 
								</EducationalMeasure> 
						</DegreeMeasure> 
				</Degree> 
		</SchoolOrInstitution> 
</EducationHistory> 
<UserArea> 
		<Id idOwner="Hiring_Bonus"> 
				<IdValue>Hiring</IdValue> 
		</Id> 
		<Id idOwner="Salary"> 
				<IdValue>5000</IdValue> 
		</Id> 
		<Id idOwner="Is_this_person_a_for"> 
				<IdValue>Test Case</IdValue> 
		</Id> 
		<Id idOwner="Start_Date"> 
				<IdValue>2013-10-01</IdValue> 
</UserArea> 
</CandidateProfile> 
<UserArea> 
<Id idOwner="Manager"> 
		<IdValue>some manager</IdValue> 
</Id> 
<Id idOwner="Managers_Email_ID"> 
		<IdValue>email address</IdValue> 
</Id> 
<Id idOwner="HR_Representative"> 
		<IdValue>test</IdValue> 
</Id> 
<Id idOwner="Onboarding_Co"> 
		<IdValue>Onboarding Coordinator</IdValue> 
</Id> 
<Id idOwner="Onboarding_Event"> 
		<IdValue>US Onboarding</IdValue> 
</Id> 
<Id idOwner="HR_Rep_email_ID"> 
		<IdValue>test email</IdValue> 
</Id> 

</UserArea> 
</Candidate>
And here is the portion of the XSLT that i need to build and what i've done so far - that fails. It always defaults to the otherwise tag no matter what is being passed on the xml. so it recognizes my Choose statement but never seems to evaluate the first When statement.

Code:
<Event>
<xsl:for-each select="hr:UserArea/hr:Id"> 
	<xsl:if test="@idOwner = 'Onboarding_Event' and hr:IdValue !=''">
		<Name><xsl:value-of select="hr:IdValue"/></Name>
	</xsl:if>	
</xsl:for-each>

<!-- Start Date -->
<xsl:for-each select="hr:CandidateProfile/hr:UserArea/hr:Id">
<xsl:if test="@idOwner = 'Start_Date' and hr:IdValue !=''">
	<Date>
	  <Name>Start</Name>
			<Value><xsl:value-of select="hr:IdValue"/></Value>
	</Date>
</xsl:if>

<!-- Category: Type of Hire is in the Candidate Profile/ User Area -->
	<xsl:if test="@idOwner = 'TypeOfHire' and hr:IdValue !=''">
		<Category>
		  <Name>Type of Hire</Name>
			<Value><xsl:value-of select="hr:IdValue"/></Value>
			<Type>Code</Type>
		</Category>
	</xsl:if>

</xsl:for-each>

<!-- People -->
<!-- User Area -->
<xsl:for-each select="hr:UserArea/hr:Id"> 
<!--THIS IS WHAT FAILS:	-->	
<xsl:choose>
<xsl:when test="@idOwner = 'Onboarding_Event' and hr:IdValue = 'US Onboarding'"> 
	  <xsl:if test="@idOwner = 'Managers_Email_ID' and hr:IdValue !=''"> 
		<Person>
		  <Name>Manager</Name>
		  <Value><xsl:value-of select="hr:IdValue"/></Value>
		</Person>
	  </xsl:if>

	   <xsl:if test="@idOwner = 'Onboarding_Co' and hr:IdValue !=''"> 
		<Person>
		  <Name>Onboarding Coordinator</Name>
		  <Value><xsl:value-of select="hr:IdValue"/></Value>
		</Person>
		</xsl:if>

	  <xsl:if test="@idOwner = 'HR_Rep_email_ID' and hr:IdValue !=''">
		<Person>
		  <Name>HR Representative</Name>
		  <Value><xsl:value-of select="hr:IdValue"/></Value>
		</Person>
	  </xsl:if>
</xsl:when>
<xsl:otherwise>											
	  <xsl:if test="@idOwner = 'Managers_Email_ID' and hr:IdValue !=''"> 
		<Person>
		  <Name>EMEA Manager</Name>
		  <Value>Test</Value>
		</Person>
	  </xsl:if>

	   <xsl:if test="@idOwner = 'Onboarding_Co' and hr:IdValue !=''"> 
		<Person>
		  <Name>EMEA Onboarding Coordinator</Name>
		  <Value>Test</Value>
		</Person>
		</xsl:if>

	  <xsl:if test="@idOwner = 'HR_Rep_email_ID' and hr:IdValue !=''">
		<Person>
		  <Name>EMEA HR Representative</Name>
		  <Value>Test</Value>
		</Person>
	  </xsl:if>
</xsl:otherwise>

</xsl:choose>
</xsl:for-each>
        </Event>