Forum Moderators: open
- <pccList>
<pcc name="LITTLE HOUSE HEALTH CENTER" cde_service_loc="A" num_phone="" adr_mail_strt1="990 DORCHESTER AVE" adr_mail_zip="02125" adr_mail_zip_4="" nam_title="" id_provider="110000013" num_area_code="" adr_mail_strt2="" adr_mail_city="DORCHESTER" adr_mail_state="MA" />
<pcc name="BETH ISRAEL HOSPITAL" cde_service_loc="C" num_phone="" adr_mail_strt1="330 BROOKLINE AVENUE" adr_mail_zip="02215" adr_mail_zip_4="" nam_title="" id_provider="110000014" num_area_code="" adr_mail_strt2="" adr_mail_city="BOSTON" adr_mail_state="MA" />
</pcclist>
My XSL:This completes normally but generats about 30 pages of blank records, what's wrong?
<?xml version="1.0"?>
<!-- ******************************************************************** -->
<!-- * This XSL is used to transform the mampcp document to * -->
<!-- * SQL script that will insert the decomposed data to our mampcpwrk file * -->
<!-- * table. * -->
<!-- ******************************************************************** -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" indent = "no" encoding="UTF-8"/>
<!-- Process complete tree starting from root-->
<xsl:template match="/">
<!-- Process each repeating MEMBER-INFO -->
</xsl:template>
<xsl:template match="pcclist">
<xsl:for-each select="pcc">
insert into mampcpwrk (name,prcode,wrkph2,adrln1,zipcod,zipcod4,titlcd,provno,wrkph1,adrln2,citycd,stacod)
values( '<xsl:value-of select="@name"/>',
'<xsl:value-of select="@cde_service_loc"/>',
'<xsl:value-of select="@num_phone"/>',
'<xsl:value-of select="@adr_mail_strt1"/>',
'<xsl:value-of select="@adr_mail_zip"/>',
'<xsl:value-of select="@adr_mail_zip_4"/>',
'<xsl:value-of select="@nam_title"/>',
'<xsl:value-of select="@id_provider"/>',
'<xsl:value-of select="@num_area_code"/>',
'<xsl:value-of select="@adr_mail_strt2"/>',
'<xsl:value-of select="@adr_mail_city"/>',
'<xsl:value-of select="@adr_mail_state"/>');
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
You should definitely have something like <oXygen/> to test this stuff out. I couldn't even imagine doing XSLT development without it.
BTW: The symptom of an XSLT script failing (like being fed badly-formed XML) is a blank output, or unchanged XML (depending on how you write the XSLT).
[edited by: httpwebwitch at 7:08 pm (utc) on May 12, 2008]
[edit reason] removed link [/edit]
<?xml version="1.0"?>
<!-- ******************************************************************** -->
<!-- * This XSL is used to transform the mampcp document to * -->
<!-- * SQL script that will insert the decomposed data to our mampcpwrk file * -->
<!-- * table. * -->
<!-- ******************************************************************** -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" indent="no" encoding="UTF-8"/>
<!-- Process complete tree starting from root-->
<xsl:template match="/">
<!-- Process each repeating MEMBER-INFO -->
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="pccList">
<xsl:for-each select="pcc"><xsl:text></xsl:text>insert into mampcpwrk
(name,prcode,wrkph2,adrln1,zipcod,zipcod4,titlcd,provno,wrkph1,adrln2,citycd,stacod)
values( '<xsl:value-of select="@name"/>', '<xsl:value-of
select="@cde_service_loc"/>', '<xsl:value-of select="@num_phone"
/>', '<xsl:value-of select="@adr_mail_strt1"/>',
'<xsl:value-of select="@adr_mail_zip"/>', '<xsl:value-of
select="@adr_mail_zip_4"/>', '<xsl:value-of select="@nam_title"
/>', '<xsl:value-of select="@id_provider"/>',
'<xsl:value-of select="@num_area_code"/>', '<xsl:value-of
select="@adr_mail_strt2"/>', '<xsl:value-of
select="@adr_mail_city"/>', '<xsl:value-of
select="@adr_mail_state"/>'); </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" indent = "no" encoding="UTF-8"/>
<xsl:template match="pcc">
<xsl:text>insert into mampcpwrk (name,prcode,wrkph2,adrln1,zipcod,zipcod4,titlcd,provno,wrkph1,adrln2,citycd,stacod)values(</xsl:text>
'<xsl:value-of select="@name"/>',
'<xsl:value-of select="@cde_service_loc"/>',
'<xsl:value-of select="@num_phone"/>',
'<xsl:value-of select="@adr_mail_strt1"/>',
'<xsl:value-of select="@adr_mail_zip"/>',
'<xsl:value-of select="@adr_mail_zip_4"/>',
'<xsl:value-of select="@nam_title"/>',
'<xsl:value-of select="@id_provider"/>',
'<xsl:value-of select="@num_area_code"/>',
'<xsl:value-of select="@adr_mail_strt2"/>',
'<xsl:value-of select="@adr_mail_city"/>',
'<xsl:value-of select="@adr_mail_state"/>');
</xsl:template>
</xsl:stylesheet>