anyone,
this is fairly simple (i think).
what I'm trying to do is a proof of concept...
I want to have a simple xml file that has employee info be "transformed" into a html file for the net and a voiceXML file for a phone system.
the html part is simple, got that (actually the book does,
however, the VoiceXML part has a small glitch that I'm having trouble with.
[H1]XML FILE[/H1]
Code:<?xml version="1.0"?> <employee FullSecurity="1"> <name>John Doe</name> <department>Widget Sales</department> <phone>(555)555-5555<extension>2974</extension></phone> <salary>62,000</salary> <area>3</area> </employee>
[H1]XSL 4 XML 2 HTML[/H1]
Code:<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <title><xsl:value-of select="/employee/name"/></title> </head> <body> <h1>Employee: <xsl:value-of select="/employee/name"/></h1> <p>Department: <xsl:value-of select="/employee/department"/></p> <xsl:if test="number(/employee/@FullSecurity)"> <p>Salary: <xsl:value-of select="/employee/salary"/></p> </xsl:if> <p>Location: <xsl:apply-templates select="/employee/area"/></p> </body> </html> </xsl:template> <xsl:template match="phone"> Phone: <xsl:value-of select="text()"/> x<xsl:value-of select="extension"/> </xsl:template> <xsl:template match="area"> <xsl:choose> <xsl:when test=". = '1'">Toronto</xsl:when> <xsl:when test=". = '2'">London</xsl:when> <xsl:when test=". = '3'">New York</xsl:when> <xsl:when test=". = '4'">Tokyo</xsl:when> <xsl:otherwise>Unknown Location</xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
[H1]XSL 4 XML 2 VOICEXML
the problem is that I have to escape the "<" character since it isn't allowed in XML and I need to somehow convert it back to "<" in the resulting file.Code:<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/" disable-output-escaping="yes"> >!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN" "http://cafe.bevocal.com/libraries/dtd/vxml1-0-bevocal.dtd"> >vxml version="2.0" xmlns:bevocal="http://www.bevocal.com/"> >form> >prompt>Employee: >/prompt> >prompt><xsl:value-of select="/employee/name"/>>/prompt> >prompt>Works in the department: >/prompt> >prompt><xsl:value-of select="/employee/department"/>>/prompt> >prompt>He works out of: >/prompt> >prompt><xsl:value-of select="/employee/location"/>>/prompt> >/form> >/vxml> </xsl:template> </xsl:stylesheet>
btw, I'm using XT to work the magic.
Thanks a million!
Sam





Bookmarks