troubleshooting Question

XSLTC error...java.lang.RuntimeException: Namespace for prefix has not been declared.

Avatar of jefftk99
jefftk99 asked on
Web Languages and StandardsXML
4 Comments1 Solution687 ViewsLast Modified:
I am having a problem using XSLTC.  I was currently using the default Xalan processor and tried to switch to XSLTC by setting the appropriate property.  See below

Was this:
  System.setProperty("javax.xml.transform.TransformerFactory",
                           "org.apache.xalan.processor.TransformerFactoryImpl");

It is now this:
  System.setProperty("javax.xml.transform.TransformerFactory",
                           "org.apache.xalan.xsltc.trax.TransformerFactoryImpl");
       
        this.strSheetName = p_strSheetName;
        TransformerFactory oFactory = TransformerFactory.newInstance();
        this.templates = oFactory.newTemplates(new StreamSource(p_oStyleSheetValue));

When I made this change, all of my stylesheets compiled successfully.  However, when I tried to perform a transform of XML I get the following error.
java.lang.RuntimeException: Namespace for prefix 'srvc' has not been declared.

Here is my stylesheet
****
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:srvc="http://doc.state.nc.us/1.0/doc-services"
      xmlns:data="http://doc.state.nc.us/1.0/doc-data"      
      xmlns:java="xalan://us.nc.state.doc.facade.ejb.asicache.ASICacheUtil"
      xmlns:codeConstants="xalan://us.nc.state.doc.ws.core.constants.CodeConstants"
      exclude-result-prefixes="java codeConstants" version="2.0">

      <!-- THESE ARE VARIABLES SET FROM OUTSIDE THE STYLESHEET -->
      <xsl:param name="TOTALRECORDS" />
      <xsl:param name="SERVICENAME" />

      <xsl:output method="xml" indent="no" encoding="UTF-8" version="1.0" />
      <xsl:template match="/">
            
            <xsl:variable name="COMPLETESERVICENAME" select="concat('srvc:', $SERVICENAME, 'Response')"/>
             <xsl:element name="{$COMPLETESERVICENAME}">      
                  <data:FacilityId><xsl:value-of select = "./JobClassificationInquireSummary/facilityId" /></data:FacilityId>
                  <data:TotalRecords><xsl:value-of select = "$TOTALRECORDS" /></data:TotalRecords>                  
                  <srvc:JobClassificationSummaryList>
                        <xsl:for-each select="./JobClassificationInquireSummary/jobClassificationSummaryList/JobClassificationItem">
                              <srvc:JobClassificationSummaryListElement>
                                    <data:StaffId><xsl:value-of select="./staffId" /></data:StaffId>
                                    <data:StaffIdName><xsl:value-of select="./staffName" /></data:StaffIdName>
                                    <data:StaffPositionNumber><xsl:value-of select="./positionNumber" /></data:StaffPositionNumber>                                                
                              </srvc:JobClassificationSummaryListElement>
                        </xsl:for-each>
                  </srvc:JobClassificationSummaryList>
            </xsl:element>
      </xsl:template>
</xsl:stylesheet>

****

Here is a sample XML file that I transform.
****

<?xml version="1.0" encoding="UTF-8"?>
<JobClassificationInquireSummary>
    <facilityId>1234</facilityId>
    <jobClassificationSummaryList>          
        <JobClassificationItem>
            <staffId>XXX01</staffId>
            <staffName>Jane Doe</staffName>
            <positionNumber>00000</positionNumber>
            <assignedDate class="sql-date">2000-07-24</assignedDate>
            <statusCode>A</statusCode>
            <statusDate class="sql-date">2006-05-15</statusDate>
            <staffType>DC</staffType>
            <jobClassCode>00000</jobClassCode>
            <workAssignment>A34</workAssignment>
            <licenseNumber/>
            <licenseExpirationDate class="sql-date">0001-01-01</licenseExpirationDate>
            <workPhoneNumber>1234567890</workPhoneNumber>
            <workPhoneExt>999</workPhoneExt>
            <pasgePhoneNumber/>
            <homePhoneNumber/>
            <apptCalLimitSunday/>
            <apptCalLimitMonday/>
            <apptCalLimitTuesday/>
            <apptCalLimitWednesday/>
            <apptCalLimitThursday/>
            <apptCalLimitFriday/>
            <apptCalLimitSaturday/>
            <userId/>
            <authlevel>B3</authlevel>
            <defaultPrinter/>
            <secAdmFacility>3060</secAdmFacility>
            <supervisorNumber>XXX03</supervisorNumber>
            <dateofUpdate class="sql-date">2006-03-06</dateofUpdate>
            <timeOfUpdate class="sql-time">14:06:25</timeOfUpdate>
            <staffOfUpdate>ZZZ04</staffOfUpdate>
            <faxNumber>1234567890</faxNumber>
            <courierNumber>000001</courierNumber>
            <idCardIssueNumber>02</idCardIssueNumber>
            <unitId/>
            <altPhoneNumber/>
            <idVerificationCode>V</idVerificationCode>
            <mailingAddress>701 FOO BAR RD.</mailingAddress>
            <city>NOWHERE</city>
            <state>XX</state>
            <zip>12345</zip>
            <emailAddress/>
            <workAddress/>
            <workCity/>
            <workState/>
            <workZip/>
            <pagerExt/>
            <functionalAreaCode/>
            <advDaysToBeScheduled/>
            <minDaysToBeScheduled/>
            <genderCode/>
            <race/>
            <height/>
            <weight/>
            <hairCode/>
            <eyeColorCode/>
        </JobClassificationItem>
    </jobClassificationSummaryList>
    <returnCode>0000</returnCode>
    <returnMessage>Success</returnMessage>
    <errorSeverity>Info</errorSeverity>
</JobClassificationInquireSummary>

****


Any help is much appreciated!
Thank you in advance.

ASKER CERTIFIED SOLUTION
DarthMod

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros