homepage Welcome to WebmasterWorld Guest from 23.20.28.193
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Help on Writing Simple Personal Information Manager (PIM) using XML
XML Help
johnvicencio




msg:4335335
 6:52 pm on Jul 5, 2011 (gmt 0)

I'm trying write a simple PIM using XML into HTML with tables and using example useage of, xsl:value-of, xsl:if.

On XML -- I have something like this --
<?xml version="1.0"?>
<!DOCTYPE PHONEBOOK [
<!ELEMENT PHONEBOOK (LISTING)>
<!ELEMENT LISTING (FIRST,LAST,PHONE+,ADDRESS+,CITY+,STATE+,ZIP+)>
<!ELEMENT FIRST (#PCDATA)>
<!ELEMENT LAST (#PCDATA)>
<!ELEMENT PHONE (#PCDATA)>
<!ATTLIST PHONE
TYPE CDATA #REQUIRED>
]>
<PHONEBOOK>
<LISTING>
<FIRST>John</FIRST>
<LAST>Smith</LAST>
<COMPANY>J and S Inc.</COMPANY>
<PHONE TYPE="WORK">1-800-123-4567</PHONE>
<PHONE>1-619-699-9999</PHONE>
<PHONE TYPE="FAX">1-619-676-8900</PHONE>
<ADDRESS TYPE="BUSINESS">123 4th Ave.</ADDRESS>
<CITY TYPE="BUSINESS">San Diego</CITY>
<STATE TYPE="BUSINESS">CA</STATE>
<ZIP TYPE="BUSINESS">92116</ZIP>
<ADDRESS>123 4th Ave.</ADDRESS>
<CITY>San Diego</CITY>
<STATE>CA</STATE>
<ZIP>92116</ZIP>
<EMAIL>jsmith@email.com</EMAIL>
<DOB>01-02-1980</DOB>
</LISTING>
Etc.

On XLS - I have something like ---

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>My Phone Book</TITLE>
</HEAD>
<BODY BGCOLOR="WHITE">
<TABLE BORDER="1">
<xsl:for-each select="//LISTING">
<xsl:sort select="LAST"/>
<TR>
<TD><B>Name:</B></TD>
<TD><FONT COLOR="GREEN"><xsl:value-of select="FIRST"/><BR/>
<xsl:value-of select="LAST"/></FONT></TD>
</TR>
<TR><TD><B>Phone:</B></TD>
<TD><FONT COLOR="RED" SIZE="+2"><xsl:value-of select="PHONE"/>
<xsl:choose>
<xsl:when test="boolean(PHONE/@TYPE) = 1">
- <xsl:value-of select="PHONE/@TYPE" />
</xsl:when>
<xsl:otherwise>
- HOME
</xsl:otherwise>
</xsl:choose>
</FONT>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>


I could never maket it to work. Any ideas or suggestions? Thanks.

 

httpwebwitch




msg:4335369
 8:07 pm on Jul 5, 2011 (gmt 0)

Hi johnvicencio, welcome to WebmasterWorld!

I haven't seen a <font> tag in years. You're old-school.

One issue could be the boolean() casting. Not all XSLT parsers support that. <xsl:sort> is also not ubiquitous; I think that's XSLT2.0, though I'll admit I'd have to look it up to be certain. Depending on the device/system this is running on, you may be limited by the XSLT engine and whether it supports those advanced features.

If the struggle continues, you could try an XSLT debugging tool like Altova or oXygen, where you'll be able to run the transformation and get a line number where it failed.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved