XML/XSLT and foreign letters = problem?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: XML/XSLT and foreign letters = problem?

  1. #1
    Peter Guest

    XML/XSLT and foreign letters = problem?


    I've made an ASP script that searches(very simply) in a database of books,
    it works fine, and now ive modified it so that it output XML instead of HTML.
    It works alright, but the XSTL parser crashes whenever it encounters a foreign
    letter( like ,, ). This a big problem as the database im searching in
    contains danish books, which are quite fond of using "weird" letters
    Ive had this problem before, but this time i sort of have to find a solution

    Below is listed both the error, and both(ASP/XML & XSL) files, i apologize
    for this making the post so long, but i find its easier for people to help,
    when they can see all the source/error messages.

    The error is:
    "The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and
    then click the Refresh button, or try again later.

    --------------------------------------------------------------------------------

    An invalid character was found in text content. Error processing resource
    'http://www25.brinkster.com/ziphnor/dbconnXML.asp?Input=database&Submit=Submit+Query'.
    Line 1, Position 140


    <?xml version='1.0'?><?xml-stylesheet type='text/xsl' href='search.xsl'?><search><searchparam>database</searchparam><result><tit>Database-h
    "
    [the full title of the book is Database-hndbogen ;(]

    Content of the asp script file(dbconnXML.asp):

    <%
    dim lineNum, str1
    lineNum = Request.QueryString("lineNum")
    str1 = Request.QueryString("Input")
    Response.Write "<?xml version='1.0'?>"
    Response.Write "<?xml-stylesheet type='text/xsl' href='search.xsl'?>"
    Response.Write "<search>"
    Response.Write "<searchparam>"&str1&"</searchparam>"

    Set Conn = Server.CreateObject("ADODB.Connection")
    sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Server.MapPath("\ziphnor\db\bibdata.mdb")
    & ";" & _
    "Persist Security Info=False"
    Conn.Open(sConnection)
    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open "SELECT tit,subtit FROM bibdata2 WHERE tit LIKE '%" & str1 &"%'",
    Conn
    If RS.EOF And RS.BOF Then
    Response.Write "There are 0 records."
    Else
    RS.MoveFirst
    While Not RS.EOF
    Response.Write "<result>"
    Response.Write "<tit>" & RS.Fields("tit") & "</tit>"
    Response.Write "<subtit>" & RS.Fields("subtit") & "</subtit>"
    Response.Write "</result>"
    RS.MoveNext
    Wend
    End If

    Response.Write("<b>Closing connection... </b><br />")
    Conn.close()
    Response.Write "</search>"
    %>

    Content of the XSL template file(search.xsl):
    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    <xsl:template match="/">
    <html>
    <style type="text/css">
    body {font-family: garamond}
    </style>
    <body>
    THIS IS THE XSL TEMPLATE SPEAKING: <br />
    <big>Result for: <xsl:value-of select="search/searchparam"/></big><br />
    <hr /><hr />
    <xsl:for-each select="search/result">
    <xsl:value-of select="search/tit"/><br />
    <xsl:value-of select="search/subtit"/><br />
    <hr />
    </xsl:for-each>
    <hr />
    </body>
    </html>
    </xsl:template>
    </xsl:s


  2. #2
    Peter Guest

    Re: XML/XSLT and foreign letters = problem?


    "in code", what do you mean by that? Im a bit of a beginner in the realm of
    XML, so if you could elaborate a bit, id be mighty pleased


    "Thomas Eyde" <thomas.eyde@online.no> wrote:
    >I struggled with the same problem some days ago. The easiest fix is to use
    >the MSXML parser to create the XML in code.
    >
    >/Thomas



  3. #3
    Thomas Eyde Guest

    Re: XML/XSLT and foreign letters = problem?

    I struggled with the same problem some days ago. The easiest fix is to use
    the MSXML parser to create the XML in code.

    /Thomas



  4. #4
    Thomas Eyde Guest

    Re: XML/XSLT and foreign letters = problem?

    Create a MSXML.DomDocument object and use its functionality to add elements.
    Use its xml property to access the data as text.

    /Thomas



  5. #5
    Pierre Lamontagne Guest

    Re: XML/XSLT and foreign letters = problem?


    I'm not sure if this can help you (because I'm also new to XML) but here goes.
    The XML I'm working on contains french characters () so in order for DOM
    parsers to work I added a Encoding attribut in my XML.

    <?xml version="1.0" encoding="ISO-8859-1" ?>

    This enable the parser to process correctly my XML. Here are other encoding
    scheme : UTF-8, UTF-16, EUC-JP, Shift_JIS, Big5, GB-2312, ...

    Hope this can help.





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center