Question
· Jun 27, 2017

How to Manage XSLT Conversion in HealthShare

Hi,

Can you please tell us how to create xsl file for CCD to SDA conversion using XSLT.

What will be the prerequisites.

I have tried to create an xsl file for the given xml given belowusing XSLT transform Wizrad:

<?xml version="1.0" ?>
<s1 title="s1 title attr">
  <s2 title="s2 title attr">
    <s3 title="s3 title attr">Content</s3>
  </s2>
</s1>

using the stylesheet below:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
 
<xsl:template match="//@* | //node()">
  <xsl:copy>
    <xsl:apply-templates select="@*"/>
    <xsl:apply-templates select="node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="/s1/s2/s3">
<xsl:apply-templates select="@*"/>
<xsl:copy>
Content Replaced
</xsl:copy>
</xsl:template>  

</xsl:stylesheet>

I got an error :

Thanks,

Shobha

Discussion (2)0
Log in or sign up to continue

There's no need to search for the /s1/s2/s3 in the second template, as the first template would send every node into the second template. So your XSLT should probably look like this:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" indent="yes"/>
     
    <xsl:template match="//@* | //node()">
        <xsl:copy>
            <xsl:apply-templates select="@*"/>
            <xsl:apply-templates select="node()"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="//s3" >
        <xsl:copy>
            <xsl:apply-templates select="@*"/>
            Content Replaced
        </xsl:copy>
    </xsl:template>
    
</xsl:stylesheet>

Hi Shobha,

Can you please tell us how to create xsl file for CCD to SDA conversion using XSLT.

What will be the prerequisites.

Standard XSLT transforms to turn CCD documents (both v1.1 CCDA CCDs, and v1.0 C32 CCDs) into SDA come with all distributions of HealthShare. Unless you have some very specific requirements, I highly recommend using those transforms or at least using them as a starting point.  You can find them either on your filesystem in the [HealthShare Install Directory]/csp/xslt/SDA3 directory or via Studio in the HSLIB namespace as csp files in the SDA3 directory underneath the /csp/xslt application if it is setup.  The root transforms are CCDA-to-SDA.xsl for CCDA CCDs and CDA-to-SDA.xsl for C32 CCDs. Many of the details of the transforms are in imported stylesheets under the CDA-Support-Files directory.

Regarding your error: "XML or TEXT declaration must start at line 1, column 1". I believe that it is a problem with your input file, not your transform. Typically, that error means that you have some tabs, spaces, or return characters at the top of your file so that the characters

<?xml version="1.0"?>

are not the first characters in the file.  Try cleaning up your input XML file and see if that resolves your error.

Karl Naden
Principal HealthShare Architect, J2 Interactive