Skip to Content
avatar image
Former Member

XSLT Mapping in HCI to Sort Compound Employee

Hi

I'm using an XSLT mapping to sort the job_information element by last_modified_on. My input structure is input.txt my XSLT mapping is fullsortbydate.txt. It works output.txt the job_information elements are in reverse order, but all the sub-elements of employment_information are missing WHY!!???

This is driving me mad.

Sorry about the text files, but it wouldn't let me upload XML or XSL files.

Thanks

Jonathan

input.txt (32.1 kB)
output.txt (30.9 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    May 25, 2017 at 07:08 AM

    Hello Jonathan,

    You have tweak your XSLT a little to copy all the EmployementInformation elements.Below code will do the same ( there might be shorter code do the same)

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
    
      <xsl:template match="@* | node()">
        <xsl:copy>
          <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
      </xsl:template>
      
      <xsl:template match="//CompoundEmployee/person/employment_information">
      <xsl:copy>
        <assignment_class>
        <xsl:value-of select="assignment_class"/>
        </assignment_class>
                    <created_by>
                    <xsl:value-of select="created_by"/>
                    </created_by>
                    <created_on_timestamp>
                    <xsl:value-of select="created_on_timestamp"/>
                    </created_on_timestamp>
                    <custom_string1>
                    <xsl:value-of select="custom_string1"/>
                    </custom_string1>
                    <custom_string2>
                    <xsl:value-of select="custom_string2"/>
                    </custom_string2>
                    <custom_string3>
                    <xsl:value-of select="custom_string3"/>
                    </custom_string3>
                    <direct_reports>
                    <xsl:value-of select="direct_reports"/>
                    </direct_reports>
                    <employment_id>
                    <xsl:value-of select="employment_id"/>
                    </employment_id>
                    <isContingentWorker>
                    <xsl:value-of select="isContingentWorker"/>
                    </isContingentWorker>
                    <jobNumber>
                    <xsl:value-of select="jobNumber"/>
                    </jobNumber>
                    <last_modified_by>
                    <xsl:value-of select="last_modified_by"/>
                    </last_modified_by>
                    <last_modified_on>
                    <xsl:value-of select="last_modified_on"/>
                    </last_modified_on>
                    <originalStartDate>
                    <xsl:value-of select="originalStartDate"/>
                    </originalStartDate>
                    <start_date>
                    <xsl:value-of select="start_date"/>
                    </start_date>
                    <user_id>
                    <xsl:value-of select="user_id"/>
                    </user_id>    
          <xsl:apply-templates select="job_information">
            <xsl:sort select="last_modified_on"/>
          </xsl:apply-templates>
          
          <xsl:apply-templates select="compensation_information">
            <xsl:sort select="last_modified_on"/>
          </xsl:apply-templates>
          
          <xsl:apply-templates select="associated_employee_information">
            <xsl:sort select="last_modified_on"/>
          </xsl:apply-templates>
          
        </xsl:copy>
      </xsl:template>
      
    </xsl:stylesheet>

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Sriprasad

      This works absolutely fine.

      Your a clever guy! Thanks a lot for your help.

      Cheers

      Jonathan