Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT Template Problem - is it possible to resume on error?

Status
Not open for further replies.

bobetko

Programmer
Jan 14, 2003
155
US
I am complete beginner. In last 2 days I did some reading, learned more about XML and XSLT and now I have more question to ask,

I want to use XSLT stylesheet (and ASP) to generate and save HTML pages.

I will use ASP to create XML input. Data will come from SQL table. My XML and XSLT should look something like this:
XML:
Code:
<allcards>
 <card>
  <name>John</name>
  <phone>111-111-1111</phone>
  <fax>222-222-2222</fax>
 </card>
 <card>
  <name>Marco</name>
  <phone>333-333-3333</phone>
  <fax>444-444-4444</fax>
 </card>
</allcards>
XSLT:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:template match="/">
  <html>
  <body>
    <h2>My Cards</h2>
    <table border="1">
    <xsl:for-each select="allcards/card">
    <tr>
      <td><xsl:value-of select="name"/></td>
      <td><xsl:value-of select="phone"/></td>
      <td><xsl:value-of select="fax"/></td>
    </tr>
    </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template></xsl:stylesheet>

I am using XMLDOM (asp/vb) to transform XML to HTML.
It's working perfect. But there is one problem.

Since XSLT file will be given to users to change it the way they like it, I assume they will be making all kind of a errors: improper tags (not xml compliant), sintax errors, etc. (like typing <br> instead of <br />). If they make any error, my asp page will crash reporting: The stylesheet may be empty, or it may not be a well-formed XML document. So, question is:
Is it possible to force XSLT to execute even though it contains improper sintax? Let's say user forgot to close img tag ( <img src="something.gif" ). I would like to generate impropert HTML and let browser deal with error when it attempts to read generated HTML?


Second part of my question: (it may bring some light)

I was looking around for solution and I ran on a code below. The code is a template (on the blog website) that client can customize and save. It defines layout for the webpage, and it is used to generate HTML page that can be viewed. Exactly what I need. Here is the sample code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]

<html>
<head>
<title><$BlogName$></title>
</head>
<body
 ....
 html content
 ....
 <blog>		
  <post>
    <postdate><h2><$postDate$>,<$postTime$></h2></postdate>
    <postname><h3><$postName$></h3></postname>
    <postcontent><$postContent$></postcontent>
  </post>
 </blog>
 ...
 html content
 ...
</body>
</html>

I assume above code is XHTML? If it is, how come code has custom tags? Does anybody have idea how the above code works?

Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top