Results 1 to 9 of 9

Thread: XML Entities

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 1999
    Posts
    27

    Question XML Entities

    I have an XML document that references an external dtd. In the dtd I have a list of entities, for some foreign characters. One such entity is <!ENTITY aacute "&#.225;"> (the "." is intentionally put in there otherwise when I post, the á would appear rather than the code) - it works fine except I there is one problem.

    I also have an xsl stylesheet that I use to transform the xml document into an html document... the example code I might use to transform the document:

    Code:
    Dim xmlDoc As DOMDocument, xslDoc as DOMDocument
    
    xmlDoc.async=false
    xslDoc.async=false
    
    xmlDoc.load app.path & "\doc.xml"
    xslDoc.load app.path & "\doc.xsl"
    
    Text1.Text = xmlDoc.transformNode(xslDoc)
    Everything transforms properly, and then I display the output html document in the webbrowser. Everything displays correctly except the "á" which shows up as a little box - to make an already long story a bit shorter, the transformNode creates a META tag in the html document setting the charset=UTF-16. The letter "á" is not in that charset, but the transform node resolves the &#.225; entity to the "á" rather than just passing the &#.225; to the html document.

    I found that I could remedy the problem by parsing the file and removing the charset declaration, but I would rather transform the document putting &#.225; in the html document rather than the actual letter "á" so that the UTF-16 charset can remain in place.

    Any suggestions? Thanks in advance!
    Last edited by Cougar0119; Jun 6th, 2001 at 02:24 PM.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Did you intentioanlly leave out the ; in your Entity you showed? Is that how it is in your code. Chcek on that..
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 1999
    Posts
    27

    oops - it's there

    I didn't copy and paste it, I just typed it and forgot it... it is in the dtd though... <!ENTITY aacute "&#.225;">

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    What character set is it in? UTF-8?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 1999
    Posts
    27

    nope...

    it's in iso-8859-1 - the Western European character set...

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    A guess, buttry adding this to your xsl file right below xsl:stylesheet
    Code:
    <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" omit-xml-declaration="no" indent="no" media-type="text/html"/>
    Dont know if it will do any good, but try it out
    Last edited by Cander; Jun 6th, 2001 at 02:51 PM.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    oof ...that should be a : o without the space instead of
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Mar 1999
    Posts
    27

    well...

    I modified your xsl output statement just a bit, and it pretty much works... I say "pretty much" because it displayed correctly but the output to the html file still isn't what I'd like... it may be something I just have to deal with... you solved the problem, but not the way I would have liked to see it fixed.

    Maybe if I rephrase my initial question... is there anyway to pass my entity value, "&#.225;" as a literal string rather than have transformNode change it to the "á"? I want transformNode to pass "&#.225" instead...

    My reason is this - I don't know if all browsers/platforms/whatever supports the iso-8859-1 character set... UTF-16 - everything supports that charset... maybe this is just something that I'm just gonna have to deal with... I don't know - any other suggestions?

    Thanks for the help!

  9. #9
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    CAnt really think of anything else. But If I can figure anything out Ill let you know.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width