Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2008-10-21
18
1,434 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
ID: 22773980
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
ID: 22777801
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
ID: 22778210
same problem with the second meta tag
 <meta name="description" content="[various entries]"/>
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:kgm2002
ID: 22779134
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
ID: 22779440
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
ID: 22779545
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
ID: 22779561
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
ID: 22779572
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
ID: 22780314
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
 

Author Comment

by:kgm2002
ID: 22787449
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
ID: 22787474
Have I mentioned I'm a complete novice at XML/XSLT?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22788000
<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
ID: 22789649
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
ID: 22789689
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
ID: 22790357
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
ID: 22882372
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
ID: 24106409
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
ID: 24109471
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

840 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