Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6386405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:01:21+00:00 2026-05-25T03:01:21+00:00

I am looking for some help with XSLT to transform one xml file into

  • 0

I am looking for some help with XSLT to transform one xml file into another format.

The input xml file is below:

<PATIENTLIST ELAPSEDMS="234" >
    <PATIENT ID="MGH000007">
        <ADDRESS1>550 BREZHNEV ST</ADDRESS1>
        <ADDRESS2></ADDRESS2>
        <CITY>MOSCOW</CITY>
        <STATE>MA</STATE>
        <ZIP>02139</ZIP>
        <COUNTRY ISO3166-1="USSR"></COUNTRY>
        <DATEOFBIRTH>1934/04/10</DATEOFBIRTH>
        <DAYPHONE>(617) 111-1111 </DAYPHONE>
        <FIRSTNAME>TEST</FIRSTNAME>
        <HOMEPHONE>(617) 111-1111</HOMEPHONE>
        <LASTNAME>TEST MGH</LASTNAME>
        <LIMITEDACCESS>False</LIMITEDACCESS>
        <MARITALSTATUS>SINGLE</MARITALSTATUS>
        <MEDICALRECORDNUMBERS>
            <MEDICALRECORDNUMBER>
                <SITE>BWH</SITE>
                <STATUS>A</STATUS>
                <VALUE>0000007</VALUE>
            </MEDICALRECORDNUMBER>
            <MEDICALRECORDNUMBER>
                <SITE>BWI</SITE>
                <STATUS>A</STATUS>
                <VALUE>0000007</VALUE>
            </MEDICALRECORDNUMBER>
            <MEDICALRECORDNUMBER>
                <SITE>MEEI</SITE>
                <STATUS>A</STATUS>
                <VALUE>0000007</VALUE>
            </MEDICALRECORDNUMBER>
            <MEDICALRECORDNUMBER>
                <SITE>MGH</SITE>
                <STATUS>A</STATUS>
                <VALUE>0000007</VALUE>
            </MEDICALRECORDNUMBER>
            <MEDICALRECORDNUMBER>
                <SITE>SHC</SITE>
                <STATUS>A</STATUS>
                <VALUE>0000007</VALUE>
            </MEDICALRECORDNUMBER>
            <MEDICALRECORDNUMBER>
                <SITE>OLD #</SITE>
                <STATUS>M</STATUS>
                <VALUE>0000007</VALUE>
            </MEDICALRECORDNUMBER>
        </MEDICALRECORDNUMBERS>
        <MIDDLEINITIAL>R</MIDDLEINITIAL>
        <MOTHERSMAIDENNAME></MOTHERSMAIDENNAME>
        <MRNR>0000007</MRNR>
        <NAME>TEST MGH, TEST R</NAME>
        <NAMESUFFIX></NAMESUFFIX>
        <NAMEPREFIX></NAMEPREFIX>
        <PRIMARYCAREPROVIDERID>512513</PRIMARYCAREPROVIDERID>
        <PRIMARYLANGUAGE>ENGLISH</PRIMARYLANGUAGE>
        <RACE CODE1="BLACK" CODE2="" FREETEXT="">BLACK</RACE>
        <ETHNICITY CODE1="AFRICAN AMERICAN" CODE2="" FREETEXT="">AFRICAN AMERICAN</ETHNICITY>
        <RELIGION>NO PREFERENCE</RELIGION>
        <SEX>M</SEX>
        <SSN></SSN>
        <UID>101662537</UID>
        <VETERAN>NO</VETERAN>
    </PATIENT>
</PATIENTLIST>

The output file needs to look like:

<?xml version="1.0" encoding="utf-8" ?>
<eCliPSEDataIntegrationServiceRequest xmlns="http://iocent.com/eCliPSEDataIntegrationServiceRequest.xsd">
    <PatientIdentifierRecord MedicalRecordNumber="MGH000007" LastName="Person" FirstName="Test" MiddleInitial="A" DateOfBirth="04/10/1934" Operation="Add" OverwriteExistingData="true" />
    <PatientDataRecord MedicalRecordNumber="MGH000007" ParameterName="Gender" ParameterValue="2" TimeStamp="8/30/2011" Operation="Add" OverwriteExistingData="true" />
    <PatientDataRecord MedicalRecordNumber="MGH000007" ParameterName="Race" ParameterValue="1" TimeStamp="8/30/2011" Operation="Add" OverwriteExistingData="true" />
</eCliPSEDataIntegrationServiceRequest>

So I am looking to pull out the

Patient ID and use it as the MedicalRecordNumber= value

DATEOFBIRTH node as the DateOfBirth value – with format changed from YYYY/MM/DD to MM/DD/YYYY

FIRSTNAME node becomes value for FirstName

LASTNAME node becomes value for LastName

MIDDLEINITIAL node becomes value for MiddleInitial

SEX node becomes value for Gender Male=1, Female=2

RACE node becomes Value for Race – based on a lookup table (Caucasian=1,Afican American=2, etc.) –

So I need to pull out these values, get the format changed, in some cases do a table-like translation (for gender and race), and write the file out in the new format.

I am limited to XSLT 1.0

I am very new to XSLT and so any help would be greatly appreciated!!!

thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:01:21+00:00Added an answer on May 25, 2026 at 3:01 am

    Based on feedback – I am updating my solution and posting here

    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output indent="yes"/>
    
      <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
      <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
    
      <xsl:variable name='MRN'>
        <xsl:value-of select="PATIENTLIST/PATIENT/MRNR"/>
      </xsl:variable>
    
      <xsl:variable name='BirthDate'>
        <xsl:value-of select="PATIENTLIST/PATIENT/DATEOFBIRTH"/>
      </xsl:variable>
    
      <xsl:variable name="BDayYear" select="substring($BirthDate,1,4)" />
      <xsl:variable name="BDayMonth" select="substring($BirthDate,6,2)" />
      <xsl:variable name="BDayDay" select="substring($BirthDate,9,2)" />
    
      <xsl:variable name='BirthDateUse'>
        <xsl:value-of select="concat($BDayMonth, '/', $BDayDay, '/', $BDayYear)"/>
      </xsl:variable>
    
      <xsl:variable name='Gender'>
        <xsl:if test="translate(PATIENTLIST/PATIENT/SEX, $smallcase, $uppercase)='M'">1</xsl:if>
        <xsl:if test="translate(PATIENTLIST/PATIENT/SEX, $smallcase, $uppercase)='F'">2</xsl:if>
      </xsl:variable>
    
      <xsl:variable name='RaceUC'>
        <xsl:value-of select="translate(PATIENTLIST/PATIENT/RACE, $smallcase, $uppercase)"/>
      </xsl:variable>
    
      <xsl:variable name='Race'>
        <xsl:choose>
          <xsl:when test="$RaceUC='WHITE'">1</xsl:when>
          <xsl:when test="$RaceUC='BLACK'">2</xsl:when>
          <xsl:when test="$RaceUC='AFRICAN AMERICAN'">2</xsl:when>
          <xsl:when test="$RaceUC='HISPANIC'">3</xsl:when>
          <xsl:when test="$RaceUC='ASIAN'">4</xsl:when>
          <xsl:when test="$RaceUC='NATIVE AMERICAN'">5</xsl:when>
          <xsl:when test="$RaceUC='INDIAN'">6</xsl:when>
          <xsl:otherwise>7</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
    
      <xsl:variable name='Operation'>
        <xsl:value-of select="'Add'"/>
      </xsl:variable>
    
      <xsl:variable name='Overwrite'>
        <xsl:value-of select="'true'"/>
      </xsl:variable>
    
      <xsl:template match="/">
        <eCliPSEDataIntegrationServiceRequest xmlns="http://iocent.com/eCliPSEDataIntegrationServiceRequest.xsd">
          <PatientIdentifierRecord
            MedicalRecordNumber="{$MRN}"
            LastName="{PATIENTLIST/PATIENT/LASTNAME}"
            FirstName="{PATIENTLIST/PATIENT/FIRSTNAME}"
            MiddleInitial="{PATIENTLIST/PATIENT/MIDDLEINITIAL}"
            DateOfBirth ="{$BirthDate}"
            Operation="{$Operation}"
            OverwriteExistingData="{$Overwrite}"
          />
          <PatientDataRecord
              MedicalRecordNumber="{$MRN}"
              ParameterName="Gender" ParameterValue="{$Gender}"
              Operation="{$Operation}"
              OverwriteExistingData="{$Overwrite}"
              />
          <PatientDataRecord
            MedicalRecordNumber="{$MRN}"
            ParameterName="Race_7_Groups" ParameterValue="{$Race}"
            Operation="{$Operation}"
            OverwriteExistingData="{$Overwrite}"
            />
        </eCliPSEDataIntegrationServiceRequest>
      </xsl:template>
    </xsl:stylesheet>
    

    Thank you for the feedback and suggestions.

    This version handles case conversion/comparison as well as formatting the bday in a format that I needed.

    I like the AVT syntax to simplify the code and the to remove the “manual formatting” that I was doing – thanks for those tips!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for an online introduction to occam 2. Could some one help me?
I'm looking for some help with dynatree plugin. I need to transform the json
I'm looking for some help with PHP File Upload. I'm trying to upload an
I'm looking for some help/suggestions for backing up two large databases to one server
Looking for some help with a Labview data collection program. If I could collect
Looking for some help! I need to split a string at the last occurrence
looking for some help with images referenced within the stylesheet. I have no problems
Hi I'm looking for some help in mapping the following tables to a hibernate
I'm looking for some help on my discussion. We're discussing two solutions to a
I'm looking for some help with a dependency issue. In a nutshell, I've included

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.