Solved

SAXParseException trying to create an XSLT for a Google mini search appliance

Posted on 2008-10-21
18
1,411 Views
Last Modified: 2013-11-18
I'm trying to create an XSLT file to front-end a Google mini search appliance. The objective is to get the search results and/or advanced search interface to appear in a defined area in a Dreamweaver template. I plugged some code into the template from WebAssist's Dreamweaver Tools for Google (I figure I'll have to figure out how to direct it to the appliance later, as it appears to want to reference google.com). However, when I try to see the results of the XSLT file, I get this:

SAXParseException: Expected end of tag 'link' (filename.xslt,line 48, column 3)

As I look at the code in DW, the only thing in line 48 is this:

</head>

I can't figure out what it wants. The template does include two links, to stylesheets at lines 10 and 12. Neither has any links in it.

Thanks to any and all who can help with this problem. For too long our search function has come off looking like an afterthought. I'd like to nail this down so it all looks like part of the same site.

Regards,

KM
0
Comment
Question by:kgm2002
  • 9
  • 8
18 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
Well, without seeing your XSLT, I guess the problem lies with the link elements not having an end tag.
XSLT scripts need to be wellformed XML. The wellformedness parser would only know that the link element is not well formed when you close the head section. So where ever you have a link element, not properly closed inside your head element, the error wil only be prompted when closing the head element. So it makes perfect sense that if your link element is on line 12, that the error is thrown at line 48.

You will need to make the HTML snippet in your XSLT wellformed.
You can do this by changing the line with the link
<link blablabla >
into
<link blablabla />
(add a "/" before the ">")

your serialiser will throw the "/" away if you serialise as html, but the intermediate XML is wellformed

cheers

Geert
0
 

Author Comment

by:kgm2002
Comment Utility
I tossed a slash into each of the two link statements; got the same output (the error message). The code snippet below is what happened when Dreamweaver started an XSLT file and I inserted our template into it (as least as far as line 48, the </head> tag, column 3 being the letter h).
<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="" --><!DOCTYPE xsl:stylesheet  [

	<!ENTITY nbsp   "&#160;">

	<!ENTITY copy   "&#169;">

	<!ENTITY reg    "&#174;">

	<!ENTITY trade  "&#8482;">

	<!ENTITY mdash  "&#8212;">

	<!ENTITY ldquo  "&#8220;">

	<!ENTITY rdquo  "&#8221;"> 

	<!ENTITY pound  "&#163;">

	<!ENTITY yen    "&#165;">

	<!ENTITY euro   "&#8364;">

]>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

<xsl:template match="/">
 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- TemplateBeginEditable name="doctitle" -->

<title></title>

<!-- TemplateEndEditable -->

<!-- TemplateBeginEditable name="head" -->

<meta name="description" content="[various entries]">

<!-- TemplateEndEditable -->

<link rel="stylesheet" type="text/css" href="http://[domain]/styles/style.css" />
 

<link rel="stylesheet" type="text/css" href="http://[domain]/styles/print.css" media="print" />
 

<SCRIPT LANGUAGE="JavaScript" SRC="http://[domain]/scripts/date.js"></SCRIPT>

<SCRIPT LANGUAGE="JavaScript" SRC="http://[domain]/scripts/mailit.js"></SCRIPT>

<SCRIPT LANGUAGE="JavaScript" SRC="http://[domain]/scripts/searchclick.js"></SCRIPT>
 

<!--///////////////////////FLASH Scripts///////////////////////-->

<!--<SCRIPT language="javascript">AC_FL_RunContent = 0;</SCRIPT>-->

<SCRIPT src="http://[domain]/scripts/AC_RunActiveContent.js" type="text/javascript"></SCRIPT>
 

<SCRIPT LANGUAGE="JavaScript">

<!--

function PopupWindow(page,x,y)

{

top.window.open(page,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+ x +',height='+ y );

if (!PopupWindow.opener)

 PopupWindow.opener = self;

}

-->

</SCRIPT>

</head>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
same problem with the second meta tag
 <meta name="description" content="[various entries]"/>
0
 

Author Comment

by:kgm2002
Comment Utility
Slashing the second meta tag didn't do anything for the preview: Still says it expects an end to a link in line 48, column 3. In fact, here's the precise error:

SAXParseException: Expected end of tag 'link' (Untitled-1.xslt,line 48, column 3)

That is as much as gets displayed when I try to preview the page in DW.
0
 

Author Comment

by:kgm2002
Comment Utility
OK, I went through the file looking for stuff that might set off the parser. I'm now to this error message:

SAXParseException: Unterminated entity reference (test1.xslt,line 103, column 62)

Point referenced follows a "site=" in an elaborated link that calls a Google advanced search page (which I would eventually like to get into the content area of the DW template, as well as search results). The actual site name has a hyphen in it (xxx-yyy); however, either it doesn't like the square brackets (which it accepted further up the page, apparently), or there's something else it wants.

I'm attaching the file as txt. I guess they're afraid of malicious code if it were attached as xslt.
test1.txt
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
aha, the error is in the & in the url, and the XML tag
here is how to solve it
    <a href="" class="SearchLink">
      <xsl:attribute name="href">
        <xsl:text disable-output-escaping="yes"><![CDATA[ http://[altdomain]/search?restrict=[domain]&site=[site]&filter=p&output=xml_no_dtd&client=aec-www&access=p&ip=155.213.41.36&proxystylesheet=http://[domain]/search.xslt&proxycustom=<ADVANCED/>]]></xsl:text>
      </xsl:attribute>Advanced</a>

After that, you will see issues with the fact that </body> is put at the wrong place
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
what a mess, I should have posted it as code
    <a href="" class="SearchLink">

      <xsl:attribute name="href">

        <xsl:text disable-output-escaping="yes"><![CDATA[ http://[altdomain]/search?restrict=[domain]&site=[site]&filter=p&output=xml_no_dtd&client=aec-www&access=p&ip=155.213.41.36&proxystylesheet=http://[domain]/search.xslt&proxycustom=<ADVANCED/>]]></xsl:text>

      </xsl:attribute>

      <xsl:text>Advanced</xsl:text>

    </a> | 

Open in new window

0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 250 total points
Comment Utility
found a bug, sorry
    <a class="SearchLink">

      <xsl:attribute name="href">

        <xsl:text disable-output-escaping="yes"><![CDATA[ http://[altdomain]/search?restrict=[domain]&site=[site]&filter=p&output=xml_no_dtd&client=aec-www&access=p&ip=155.213.41.36&proxystylesheet=http://[domain]/search.xslt&proxycustom=<ADVANCED/>]]></xsl:text>

      </xsl:attribute>

      <xsl:text>Advanced</xsl:text>

    </a> | 

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
main other problem was a nested template (templates should not be nested) and closing to many divs and not closing html
if you then provide the variables an templates that are missing this should work
I have attached as far as I could correct it, good luck with it
test.txt
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:kgm2002
Comment Utility
Well, we're further down the page before the parser chokes, and I do thank you for that. Here's the latest exception error:

XSLT Error: The template name specified in the 'xsl:call-template' instruction was not found. (file:///[local file location]/foo, line 172, column 45.)

There is no foo there. Here's the line that throws the error:

            <xsl:call-template name="logo"/>

Column 45 appears to be the line feed at the end of the line (and the space at the left is part of the line and included in the column count). Don't know if this should be defined somewhere else or what. Since we want the results and the advanced search interface to appear as part of the rest of the web site, there really isn't any need to have any logo, ours or Google's, on the search results page or the search interface. But it appears this has a problem with a null value.

I really do appreciate your assistance.
0
 

Author Comment

by:kgm2002
Comment Utility
Have I mentioned I'm a complete novice at XML/XSLT?
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
<xsl:call-template name="logo"/>

is like a function call, but you don't have a template (function definition) in your code

you need to find something like
<xsl:template name="logo">
....
</xsl:template>
from the original XSLT

or delete the line from your XSLT

maybe for now you can comment it out, so you know later where it was
<!--xsl:call-template name="logo"/-->

you will find a number of errors like this in your stylesheet (you make quite some template calls)

next issue you will hit is that you have references to variables that are not declared

<xsl:value-of select="$someVariable"/>

get rid of those too, or declare them beforehand
<xsl:variable name="someVariable"/>

good luck

Geert
0
 

Author Comment

by:kgm2002
Comment Utility
And then I run into the apparent need for dummy data so I can test this file. After all, the original is looking for the output of a Google mini search appliance, so the source is identified as "http://". How do I create a dummy dataset for XML?
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
well, if you don't have a schema, it is kind of hard to make a dummy dataset.
I suggest that you try to get a result set from the mini search appliance and use that
0
 

Author Comment

by:kgm2002
Comment Utility
http://[altdomain]?q=[search term]&site=[site]&client=[site]&proxystylesheet=[XSLT location]&output=xml_no_dtd&restrict=[subsite]&proxyreload=1

This (obviously edited) is the URL of a results page from a search using our current function. I plugged this (unedited) into the source statement in the XSLT file and got "expected end of tag 'meta'." Cut it back to the altdomain value and got "Invalid document structure (search,line 1, column 1)." The whole of line 1 reads:

<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://[altdomain]" --><xsl:stylesheet>

Obviously, I'm close to clueless here. If we can get this figured out, I may have to raise the point value.
0
 

Author Comment

by:kgm2002
Comment Utility
Just wanted to keep this one in play, as I've been out of work for more than a week and not near the problem child that provoked this question.
0
 

Expert Comment

by:tekege
Comment Utility
Hi !
I have an Google XML returned by google .I am trying to parse the xml with xslt
but nothing happens . my XSL code is here.
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
    <h2>Display Result</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
      <th align="left">Search</th>
     
    </tr>
    <xsl:for-each select="GSP/RES">
    <tr>
      <td bgcolor="yellow"><xsl:value-of select="R/S"/></td>
   
    </tr>
    </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
Your follow up has not enough relation to the original question, so I suggest that you make this a new question
Please provide the XML source with the question
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now