SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy More XML problems -- encoding

    Now, still not got to the bottom of why XML ain't working on our live server:
    http://www.sitepoint.com/forums/showthread.php?t=171476

    However, in parallel to this (since it is working on our development server) I'm having some encoding issues. I've found this resource (which looks great):
    http://www.geocities.com/pmpg98_pt/C...rEncoding.html

    The problem I have is that I'm outputting this XML in to web page using ASP, but the ASP is automatically altering the encoding from ISO 8859-1 to UTF-16. It seems that's the standard, fine, but my XHTML is in ISO 8859-1 and it's screwing up the source and page display by spacing out the code generated by the XSL, adding a new XML declaration (which I guess will kill the validation) and causing IE to display the BOM (Byte Order Mark).

    There's an "Objects/Interfaces encoding" section at the bottom of the page I've found (see above)... I'm using method 5. But I don't want it to be converted into UTF-16 encoding and I don't want the extra XML declaration to appear in the output. One more thing. We're not hosting this site, so we're unlikely to be able to do anything that involves needing read/write permissions to a directory very easily. Any ideas?



    G

  2. #2
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried:
    Code:
    Response.Charset = "iso-8859-1"
    ?

    Also, you might want into directing the transformed output into an appropriately configured ADO.Stream object, which will convert between character sets for you without fuss. You can then stream the converted output to the browser with a simple Response.Write (or perhaps Response.BinaryWrite).

    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  3. #3
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeh, we're trying that approach but having lots of problems. Response.Charset threw a "not allowed in the collection" error so I ditched that. I think ADODB.Stream is the way forward, but how do you convert the character set with it? That's where I tried to use Response.Charset and it got upset...

    I have hams for fists when I code.

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Come on Greg, you should know the drill! Are you really telling me that you've looked up "charset" in the ADO documentation?

    Charset Property
    Indicates the character set into which the contents of a text Stream should be translated.

    Settings and Return Values
    Sets or returns a String value that specifies the character set into which the contents of the Stream will be translated. The default value is "Unicode". Allowed values are typical strings passed over the interface as Internet character set strings (for example, "iso-8859-1", "Windows-1252", etc.). For a list of the character set strings that is known by a system, see the subkeys of HKEY_CLASSES_ROOT\MIME\Database\Charset in the Windows Registry.

    Remarks
    In a text Stream object, text data is stored as Unicode. The Charset property translates the data read from the Stream into the specified character set. Similarly, data written to the Stream in the specified character set is translated into Unicode for storage in the Stream object.

    For an open Stream, the current Position must be at the beginning of the Stream (0) to be able to set Charset.

    Charset is used only with text Stream objects (Type is adTypeText). This property is ignored if Type is adTypeBinary.
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  5. #5
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Docu-what? You got me... Thanks.

  6. #6
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem with Stream is that I have to run a script and treat the output, and the Stream object has to open a file doesn't it?

  7. #7
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by greg.harvey
    The problem with Stream is that I have to run a script and treat the output, and the Stream object has to open a file doesn't it?
    Nope. You can use a Stream object as an in-memory data store, in the same way that you can use a freestanding disconnected Recordset (i.e. without a DB).

    Again, if you look at the documentation p) you should notice that all the parameters to the .Open() method are optional!

    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  8. #8
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bah!

    I understand that I can open a file and store it in the memory. What I can't do is open "http://www.foo.com/foo.xml" in to a stream so far as I can tell. It wants a local path.

  9. #9
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    >>Marcus quotes directly from the entry in the ADO reference documentation for the .Open() method<<
    A URL should be specified using the URL keyword ("URL=scheme://server/folder").


    However, more to the point, why are you loading from a remote resource anyway? The code that you posted way back earlier in this thread showed local files being loaded. When and why did this change? Aren't they on the local disk of the web server? (This may well explain why you've been having odd results from the live box...)
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  10. #10
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just noticed something that I didn't pick up on earlier...
    Quote Originally Posted by greg.harvey
    I understand that I can open a file and store it in the memory.
    That's true (obviously), but not what I was talking about.

    What I was talking about is creating an instance of the ADO.Stream object, then piping the text output of the transform directly into it, then retrieving it from the ADO.Stream in the character set that you want it in (letting it automagically convert between character sets).

    No "files" involved (as in the sense of being written/read from/stored on disk), just data streams.

    You get me now?
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  11. #11
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    Sorry. Been on holiday... how do you type again?

    I see what you mean. Thanks.

    I think in my absence a colleague got this working by changing the syntax of the Response line. I'll post a little more detail when I see what he did!

    G

  12. #12
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. He changed this line:

    Code:
    'Transform file
    xml.transformNodeToObject xsl, Response
    to this:

    Code:
    'Transform file
    Response.Write(xml.transformNode(xsl))
    And now everything works on every server.

  13. #13
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent!
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


Bookmarks

Posting Permissions

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