i have xml output below , there multiple records locations, ask have of these locations concatenated together. xml looks this:
<?xml version="1.0" encoding="utf-8"?><soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"><soapenv:body><ns1:getdocumentbykeyresponse soapenv:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.taleo.com/ws/integration/toolkit/2005/07"><document xmlns="http://www.taleo.com/ws/integration/toolkit/2005/07"><attributes><attribute name="count">1</attribute><attribute name="duration">0:00:00.407</attribute><attribute name="entity">sourcingrequest</attribute><attribute name="mode">t-xml</attribute><attribute name="version">http://www.taleo.com/ws/tee800/2009/01</attribute></attributes><content> <exporttxml xmlns="http://www.taleo.com/ws/integration/toolkit/2005/07" xmlns:e="http://www.taleo.com/ws/tee800/2009/01"> <e:sourcingrequest> <e:requisition> <e:requisition> <e:contestnumber>1604860</e:contestnumber> <e:jobinformation> <e:jobinformation> <e:otherlocations> <e:location> <e:networklocation> <e:networklocation> <e:countrylocation> <e:networklocation> <e:abbreviation>us</e:abbreviation> </e:networklocation> </e:countrylocation> <e:statelocation> <e:networklocation> <e:abbreviation>va</e:abbreviation> </e:networklocation> </e:statelocation> </e:networklocation> </e:networklocation> <e:worklocation> <e:worklocation> <e:city>fredericksburg</e:city> </e:worklocation> </e:worklocation> </e:location> <e:location> <e:networklocation> <e:networklocation> <e:countrylocation> <e:networklocation> <e:abbreviation>us</e:abbreviation> </e:networklocation> </e:countrylocation> <e:statelocation> <e:networklocation> <e:abbreviation>va</e:abbreviation> </e:networklocation> </e:statelocation> </e:networklocation> </e:networklocation> <e:worklocation> <e:worklocation> <e:city>manassas</e:city> </e:worklocation> </e:worklocation> </e:location> </e:otherlocations> </e:jobinformation> </e:jobinformation> </e:requisition> </e:requisition> <e:runtimefields> <e:runtimefield name="address1"/> <e:runtimefield name="category">corporate</e:runtimefield> <e:runtimefield name="city"/> <e:runtimefield name="lat"/> <e:runtimefield name="long"/> <e:runtimefield name="posteddate">2016-06-30</e:runtimefield> <e:runtimefield name="state"/> <e:runtimefield name="country">us</e:runtimefield> <e:runtimefield name="language">e</e:runtimefield> <e:runtimefield name="zip"/> </e:runtimefields> </e:sourcingrequest> </exporttxml></content></document></ns1:getdocumentbykeyresponse></soapenv:body></soapenv:envelope>
my xsl looks so:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:e="http://www.taleo.com/ws/tee800/2009/01" xmlns:fct="http://www.taleo.com/xsl_functions" exclude-result-prefixes="e fct"> <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/> <xsl:template match="/"> <client> <xsl:apply-templates select="//e:sourcingrequest"/> </client> </xsl:template> <xsl:template match="e:sourcingrequest"> <xsl:variable name="wegmans" select="e:runtimefields/e:runtimefield[@name='client']"/> <xsl:variable name="title" select="e:requisition/e:requisition/e:jobinformation/e:jobinformation/e:title"/> <xsl:variable name="req_number" select="e:requisition/e:requisition/e:contestnumber"/> <xsl:variable name="posted_date" select="e:runtimefields/e:runtimefield[@name='posteddate']"/> <xsl:variable name="language" select="e:runtimefields/e:runtimefield[@name='language']"/> <xsl:variable name="state_province" select="e:runtimefields/e:runtimefield[@name='state']"/> <xsl:variable name="addressline1" select="e:runtimefields/e:runtimefield[@name='address1']"/> <xsl:variable name="city" select="e:runtimefields/e:runtimefield[@name='city']"/> <xsl:variable name="zip" select="e:runtimefields/e:runtimefield[@name='zip']"/> <xsl:variable name="country" select="e:runtimefields/e:runtimefield[@name='country']"/> <xsl:variable name="lat" select="e:runtimefields/e:runtimefield[@name='lat']"/> <xsl:variable name="long" select="e:runtimefields/e:runtimefield[@name='long']"/> <xsl:variable name="category" select="e:runtimefields/e:runtimefield[@name='category']"/> <xsl:variable name="jobqualifications" select="e:requisition/e:requisition/e:jobinformation/e:jobinformation/e:externalqualificationhtml"/> <xsl:variable name="jobtext" select="e:requisition/e:requisition/e:jobinformation/e:jobinformation/e:descriptionexternalhtml"/> <xsl:variable name="agerequirement" select="e:requisition/e:requisition/e:jobinformation/e:jobinformation/e:udfs/e:udf[@name='age_5frequirement_5fw']/e:udselement/e:description"/> <xsl:variable name="dayshoursreq" select="e:requisition/e:requisition/e:jobinformation/e:jobinformation/e:udfs/e:udf[@name='days_5fhours_20requirement_5fw']"/> <xsl:variable name="schedule" select="e:requisition/e:requisition/e:jobinformation/e:jobinformation/e:jobschedule/e:jobschedule/e:description"/> wegmans <job> <title> <xsl:value-of select="$title"/> </title> <req_number> <xsl:value-of select="$req_number"/> </req_number> <posted_date> <xsl:value-of select="$posted_date"/> </posted_date> <language> <xsl:value-of select="$language"/> </language> <addressline1> <xsl:value-of select="$addressline1"/> </addressline1> <city> <xsl:value-of select="$city"/> </city> <state_province> <xsl:value-of select="$state_province"/> </state_province> <zip> <xsl:value-of select="$zip"/> </zip> <country> <xsl:value-of select="$country"/> </country> <xsl:for-each select="e:requisition/e:requisition/e:jobinformation/e:jobinformation/e:otherlocations/e:location"> <xsl:variable name="othercity" select="e:worklocation/e:worklocation/e:city"/> <xsl:variable name="otherstate" select="e:networklocation/e:networklocation/e:statelocation/e:networklocation/e:abbreviation"/> <xsl:variable name="othercountry" select="e:networklocation/e:networklocation/e:countrylocation/e:networklocation/e:abbreviation"/> <otherlocations> <xsl:value-of select="concat($othercity,'-',$otherstate,'-',$othercountry)"/> </otherlocations> </xsl:for-each> <lat> <xsl:value-of select="$lat"/> </lat> <long> <xsl:value-of select="$long"/> </long> <category> <xsl:value-of select="$category"/> </category> <jobqualifications> <xsl:value-of select="$jobqualifications"/> </jobqualifications> <jobtext> <xsl:value-of select="$jobtext"/> </jobtext> <agerequirement> <xsl:value-of select="$agerequirement"/> </agerequirement> <dayshoursreq> <xsl:value-of select="$dayshoursreq"/> </dayshoursreq> <schedule> <xsl:value-of select="$schedule"/> </schedule> <applyurl> <xsl:value-of select="concat('https://wegmans.taleo.net/careersection/2/jobapply.ftl?job=',$req_number)"/> </applyurl> </job> </xsl:template> </xsl:stylesheet>
current output based on xsl above gives this:
<addressline1/> <city/> <state_province/> <zip/> <country>us</country> <otherlocations>fredericksburg-va-us</otherlocations> <otherlocations>manassas-va-us</otherlocations> <otherlocations>leesburg-va-us</otherlocations> <otherlocations>alexandria--us</otherlocations> <otherlocations>leesburg-va-us</otherlocations> <otherlocations>hanover-va-us</otherlocations> <otherlocations>fairfax-va-us</otherlocations> <lat/>
i need so:
<addressline1/> <city/> <state_province/> <zip/> <country>us</country> <otherlocations>fredericksburg-va-us,manassas-va-us,leesburg-va-us,alexandria--us,leesburg-va-us,hanover-va-us,fairfax-va-us</otherlocations> <lat/>
simply move creation of <otherlocations>
tag outside xsl:for-each
construct, , have check inside output comma before items except first.
try xslt fragment...
<otherlocations> <xsl:for-each select="e:requisition/e:requisition/e:jobinformation/e:jobinformation/e:otherlocations/e:location"> <xsl:variable name="othercity" select="e:worklocation/e:worklocation/e:city"/> <xsl:variable name="otherstate" select="e:networklocation/e:networklocation/e:statelocation/e:networklocation/e:abbreviation"/> <xsl:variable name="othercountry" select="e:networklocation/e:networklocation/e:countrylocation/e:networklocation/e:abbreviation"/> <xsl:if test="position() > 1">,</xsl:if> <xsl:value-of select="concat($othercity,'-',$otherstate,'-',$othercountry)"/> </xsl:for-each> </otherlocations>
do note current xml sample has 2 locations though.....
Comments
Post a Comment