facing problem in XSLT transformation
843834Jun 19 2007 — edited Jun 25 2007Hi all,
I m new bie to XSLT n transformation. I have written a simple java program that uses the javax.xml.transform and javax.xml.parsers package to transform source file using a XSL file provided.
When I excuted the program providing XSLT file that worked fine and transformed the XML but when I modified the XSLT and using Xpath functions, I m getting following exception :
ERROR: 'Cannot find class 'xpath-functions'.'
FATAL ERROR: 'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:613)
at transformXML.main(transformXML.java:33)
This is my XSLT file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<Listfaultinterfaceslot>
<xsl:variable name="current_date" select="fn:string(fn:current-date())"/>
<!-- Get the components of the current date -->
<xsl:variable name="day">
<xsl:value-of select="fn:substring($current_date,9,2)"/>
</xsl:variable>
<xsl:variable name="month">
<xsl:value-of select="fn:substring($current_date,6,2)"/>
</xsl:variable>
<xsl:variable name="year">
<xsl:value-of select="fn:substring($current_date,1,4)"/>
</xsl:variable>
<xsl:variable name="formatted_date">
<xsl:value-of select="$month"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="$day"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="$year"/>
</xsl:variable>
<!-- Finally output the slots-->
<AppointmentSlot>
<xsl:attribute name="AppointmentSlotNo">1</xsl:attribute>
<xsl:attribute name="ExternalAppointmentSlotStart">
<xsl:value-of select="$formatted_date"/>
<xsl:text> 08:00:00</xsl:text>
</xsl:attribute>
<xsl:attribute name="ExternalAppointmentSlotEnd">
<xsl:value-of select="$formatted_date"/>
<xsl:text> 13:00:00</xsl:text>
</xsl:attribute>
</AppointmentSlot>
<AppointmentSlot>
<xsl:attribute name="AppointmentSlotNo">2</xsl:attribute>
<xsl:attribute name="ExternalAppointmentSlotStart">
<xsl:value-of select="$formatted_date"/>
<xsl:text> 13:00:00</xsl:text>
</xsl:attribute>
<xsl:attribute name="ExternalAppointmentSlotEnd">
<xsl:value-of select="$formatted_date"/>
<xsl:text> 18:00:00</xsl:text>
</xsl:attribute>
</AppointmentSlot>
</Listfaultinterfaceslot>
</xsl:template>
</xsl:stylesheet>
Please look into this n let me know the reason.
Thanks alot
Omesh