I'm finding it hard to create the XSLT stylesheet from the following input and output files.
Input XML:
<DocumentManagement>
<Document>
<DocUniqueID>MedTypeABC1234140204132332932CL</DocUniqueID>
<PatientID>ABC1234</PatientID>
<CreationDate>03 Feb 2014</CreationDate>
<DocumentClass>Clinical Letters</DocumentClass>
<MimeType>application/msword</MimeType>
<MetaData>
<FieldName>Original Document Creation Date</FieldName>
<Value>03 Feb 2014</Value>
</MetaData>
<MetaData>
<FieldName>Subject</FieldName>
<Value>Neurology</Value>
</MetaData>
<MetaData>
<FieldName>Description</FieldName>
<Value>Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit</Value>
</MetaData>
<MetaData>
<FieldName>Clinician</FieldName>
<Value>Dr. Adam Smith</Value>
</MetaData>
</Document>
</DocumentManagement>
Desired Output XML:
<DocumentSet>
<Comments>Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit/Comments>
<Author>
<Person value="Dr. Adam Smith" />
<Role>Clinician</Role>
<Speciality>Neurology</Speciality>
</Author>
<PatientId id="ABC1234" />
<Document umiqueId="MedTypeABC1234140204132332932CL" creationTime="03 Feb 2014" mimeType="application/msword">
<ClassCode description="Clinical Letters" />
<FormatCode value="WORD" description="application/msword" />
</Document>
</DocumentSet>
I'm having particular difficulty with:
- Comments should get value from the 3rd metadata group.
- Specialty should get value from the 2nd metadata group.
- Person and role elements should get their values from the 4th metadata group.
Can somebody please show me the correct XSLT stylesheet? Thanks in advance.
I can only come up with the XSLT below and could not, of course, get my complete desired output.
<xsl:template match="DocumentManagement/Document">
<DocumentSet>
<Comments>
<xsl:value-of select="don't know what to put here"/>
</Comments>
<Author>
<Person value="don't know what to put here" />
<Role><xsl:value-of select="don't know what to put here"/></Role>
<Speciality><xsl:value-of select="don't know what to put here"/></Speciality>
</Author>
<PatientId id="{PatientID}" />
<Document umiqueId="{DocUniqueID}" creationTime="{CreationDate}" mimeType="{MimeType}">
<ClassCode description="{DocumentClass}" />
<FormatCode value="don't know how to put correct value based on mimetype" description="{MimeType}" />
</Document>
</DocumentSet>
</xsl:template>