Go Back   SitePoint Forums > Forum Index > Program Your Site > XML and Web Services
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jul 29, 2007, 22:34   #1
tinggg
SitePoint Enthusiast
 
Join Date: Mar 2003
Location: dublin
Posts: 78
XML validation problem

Hi

When I use a url with more than one = symbol e.g.

http://www.fis.org.nz/index.php?map=yes&app=BreakOut

the xml fails to validate. The reason given is that "the production 'entity ref' not satisfied"

- I looked up the entity escape character for = and got
Code:
& # 6 1 ;
[I had to seperate the & # 6 1 ; with a space between each character in order to get them to appear here]

- I replaced the = with the entity escape character but that didn't work either.

Can anyone help me with where I am doing wrong?

Many thanks
tinggg is offline   Reply With Quote
Old Jul 30, 2007, 15:37   #2
kgun
SitePoint Addict
 
Join Date: Nov 2005
Location: Moss, Norway.
Posts: 274
Why do you use decimal character references and not entitiy references?

< = &lt;
& = &amp;
> = &gt;
" = &quot;
' = &apos;
kgun is offline   Reply With Quote
Old Jul 30, 2007, 18:42   #3
tinggg
SitePoint Enthusiast
 
Join Date: Mar 2003
Location: dublin
Posts: 78
Hi kgun

that worked for http://www.fis.org.nz/index.php?map=...p;app=BreakOut

but for http://www.minedu.govt.nz/index.cfm?...xparentid=1028

replacing '&' with &amp; doesn't render a well formed url - do you know why that is? Is there anything else in this url that I need to escape other than the '&'?

And when I replace:

http://www.careers.govt.nz/default.a...=39907&id1=305
with
http://www.careers.govt.nz/default.a...07&amp;id1=305

Though the url validates as well-formed if you put both into a browser the well-formed link appears to be broken.

Is there any online tool that converts mal-formed urls into well formed ones?

Thanks
tinggg is offline   Reply With Quote
Old Jul 30, 2007, 19:19   #4
kgun
SitePoint Addict
 
Join Date: Nov 2005
Location: Moss, Norway.
Posts: 274
Quote:
Originally Posted by tinggg View Post
but for http://www.minedu.govt.nz/index.cfm?...xparentid=1028

replacing '&' with &amp; doesn't render a well formed url - do you know why that is? Is there anything else in this url that I need to escape other than the '&'?
No I can not immediately see that if you replace all three instances of & with &amp; But I am unsure of the word "document" in the URL query. Have you tried with other words in the URL?

Quote:
Originally Posted by tinggg View Post
And when I replace:

http://www.careers.govt.nz/default.a...=39907&id1=305
with
http://www.careers.govt.nz/default.a...07&amp;id1=305

Though the url validates as well-formed if you put both into a browser the well-formed link appears to be broken.
My bolding: What do you mean?

Quote:
Originally Posted by tinggg View Post
Is there any online tool that converts mal-formed urls into well formed ones?
Try to google it with the relevant KW's. I use Dreamweaver's, inbuilt XML validator:

File + Check page + validate as xml.

Then you usually get meaningful error messages, so you find the error. That is in my way also the best way to do it, since you learn how to write well-formed code.

You find a lot of tools on my site:

MultiFinanceIT

Along the left edge under the heading "Quality control". Scroll down.

Alternatively and fast, especially in FF: CTRL + F + Quality control
kgun is offline   Reply With Quote
Old Jul 30, 2007, 20:08   #5
tinggg
SitePoint Enthusiast
 
Join Date: Mar 2003
Location: dublin
Posts: 78
thanks for the info Kgun

Quote:
Originally Posted by tinggg
And when I replace:

http://www.careers.govt.nz/default.a...=39907&id1=305
with
http://www.careers.govt.nz/default.a...07&amp;id1=305

Though the url validates as well-formed if you put both into a browser the well-formed link appears to be broken.
The mal-formed url is:
Code:
http://www.careers.govt.nz/default.aspx?id0=39907&id1=305
When I make this well-formed, by escaping the ampersand, I change the link to:
Code:
http://www.careers.govt.nz/default.aspx?id0=39907&amp;id1=305
However if I put
Code:
http://www.careers.govt.nz/default.aspx?id0=39907&amp;id1=305
in a browser I get a runtime error

Quote:
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
I don't understand why this is happening...btw, these are sites I am just linking to, I don't have any control over the source.

thanks for your help and the resources
tinggg is offline   Reply With Quote
Old Jul 30, 2007, 20:15   #6
kgun
SitePoint Addict
 
Join Date: Nov 2005
Location: Moss, Norway.
Posts: 274
Quote:
Originally Posted by tinggg View Post

I don't understand why this is happening...btw, these are sites I am just linking to, I don't have any control over the source.

thanks for your help and the resources
My bolding.

Simple answer. Because the coding from the server side is "wrong".

And the browser do not translate the url with &amp; that does not exist to the url with the &, that exists.

The correct way is for the third party to code the url with &amp; from the start to make it well-formed in the xml space.

There are a lot of such problems with affilate links. Even large providers supply mal-formed code. You have two choices:
  • Delete the link.
  • Accept invalid code.
kgun is offline   Reply With Quote
Old Jul 31, 2007, 20:23   #7
tinggg
SitePoint Enthusiast
 
Join Date: Mar 2003
Location: dublin
Posts: 78
thanks kgun - at least I now know its not something I am doing or not doing.

T
tinggg is offline   Reply With Quote
Old Aug 1, 2007, 02:55   #8
kgun
SitePoint Addict
 
Join Date: Nov 2005
Location: Moss, Norway.
Posts: 274
Some people struggle for standards. Cite from my favorite XML + PHP Robert Richards (2006) "Pro PHP XML and Web Services" Apress, paper edition, page 17.

"Except for markup delimiters or within a comment, PI or, CDATA section, & and < can never be used directly. The > character must never be used when creating a string containing ]]> within content and not being used at that time to close a CDATA section. The double and single quote characters must never be used in literal form within an attribute value. Attribute values may be enclosed within either double or single quotes, so to avoid potential conflicts, those characters are not allowed within the value. All these characters, according to their particular rule sets, must be represented using either the numeric character references or the entity references."

My bolding.

Recommendation 1: Never advice a person new to web development to learn HTML. Say that (s)he should not learn that bad dialect. Advice her / him to learn XML or at least XHTML from the very start. Then (s)he will be used to write well-formed code from the beginning and (s)he will have no problem understanding HTML.

Recommendation 2: Buy the above book of Robert Richards if you do not already own it. It is soon, not least if you care about developing for Web 2.0 (AJAX and XML driven sites etc.) worth it's weight in gold.

Related thread: The XML family of technologies will revolutionize web linking etc.

Note: There is also a new trend on databases. Object oriented databases have not been so popular so long, even if they should since they are much more flexible than traditional relational database. E.g. in a pure OO database, a relation is a reference and fields can contain mixed content etc. Native XML databases (NXD) specializes in XML storage. An NXD, uses XML technologies like XPath and the Document Object Model (DOM) to create and manipulate documents within the database. Traditional relational databases, however, have also made strides in this area. Many begin to include advanced XML features.

Think of the flexibility of an OO Database. You can store a movie in one record (row) and a picture in another record in the same field (column).

Time will show if the NDX concept becomes the final starter (and driver) for OO (relational) Databases like Versant and FlexPro

P. S. I was so lucky that I participated at a lecture with Kristen Nygaard on this topic (OODB PHYLA) and BETA before he died.

Last edited by kgun; Aug 1, 2007 at 03:49.
kgun is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 18:02.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved