I'm new to XSLT and have managed to work with XML where the nodes are repeated for each row. I've been given some XML to import that has different elements for each patient record, for example:
<?xml version="1.0" encoding="utf-8"?>
<data>
<patient>
<link_id>123</link_id>
<diagnoses>
<diabetes_type2>
<diabetes_type2_active>True</diabetes_type2_active>
<diabetes_type2_description>diabetes mellitus</diabetes_type2_description>
<diabetes_type2_diagnosis_date>06051999</diabetes_type2_diagnosis_date>
</diabetes_type2>
</diagnoses>
</patient>
<patient>
<link_id>456</link_id>
<diagnoses>
<chd>
<chd_active>True</chd_active>
<chd_description>ischaemic heart disease</chd_description>
<chd_diagnosis_date>05071997</chd_diagnosis_date>
</chd>
<coad>
<coad_active>True</coad_active>
<coad_description>chronic obstructive airways disease</coad_description>
<coad_diagnosis_date>28011986</coad_diagnosis_date>
</coad>
<depression>
<depression_active>True</depression_active>
<depression_description>depression</depression_description>
<depression_diagnosis_date>28011986</depression_diagnosis_date>
</depression>
<myocardial_infarction>
<myocardial_infarction_active>True</myocardial_infarction_active>
<myocardial_infarction_description>myocardial infarction</myocardial_infarction_description>
<myocardial_infarction_diagnosis_date>05071997</myocardial_infarction_diagnosis_date>
</myocardial_infarction>
<osteoarthritis>
<osteoarthritis_active>True</osteoarthritis_active>
<osteoarthritis_description>osteoarthritis of the knee</osteoarthritis_description>
<osteoarthritis_diagnosis_date>28011986</osteoarthritis_diagnosis_date>
</osteoarthritis>
<stroke>
<stroke_active>True</stroke_active>
<stroke_description>cerebrovascular accident</stroke_description>
<stroke_diagnosis_date>01011996</stroke_diagnosis_date>
</stroke>
</diagnoses>
</patient>
</data>
I need to import the diagnoses values but I don't want to hard code all the hundreds of possible values that could appear. I was hoping there was a way I could dynamically reference these regardless of their element name. I would typically use something like this:
<xsl:for-each select="./data/patient/diagnoses">
<ROW MODID="" RECORDID="">
<COL>
<DATA>
<xsl:value-of select="../../link_id"/>
</DATA>
</COL>
<COL>
<DATA>
<xsl:value-of select="./type"/>
</DATA>
</COL>
<COL>
<DATA>
<xsl:value-of select="./description"/>
</DATA>
</COL>
<COL>
<DATA>
<xsl:value-of select="./active"/>
</DATA>
</COL>
<COL>
<DATA>
<xsl:value-of select="./diagnosis_date"/>
</DATA>
</COL>
</ROW>
</xsl:for-each>
but not sure how to modify this for the dynamic elements that I'm now working with.