Results 1 to 10 of 10

Thread: XML Attributes

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Kettering, Northants, England
    Posts
    56
    You may well have to declare those characters as entities.

    Not sure but there may also be a character set issue in the xml directive at the top of the file.

  2. #2
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    OK, sounds good, but...

    since I don't know a great deal about XML, how do I do that?

    Entities, what?

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Kettering, Northants, England
    Posts
    56
    Have a look here:

    http://www.xml.com/pub/a/2001/01/31/qanda.html

    Found from doing a search on Google: entities special characters xml

    Are those characters part of the standard ASCII character set?

    Dave

  4. #4
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Getting there slowly..

    So I need to declare them somehow? In a DOCTYPE element?

    The reference you posted talks about DTD, I'm using a schema (XSD) how does all that hang together

    The sorts of characters I'm using are:

    ° = ALT+248
    ± = ALT+177
    ² = ALT+0178
    ³ = ALT+0179

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Kettering, Northants, England
    Posts
    56
    Yes that's right you need to declare them in a DTD (DOCTYPE element).

    I suggest you take a few hours out to learn about DTDs, they really are quite simple. Don't think of XML as anything other than self-describing data (in markup form).

    I learnt about DTDs a while back - just starting on Schemas. Take a look here:

    http://www.xml101.com/dtd/default.asp

    And here:

    http://lists.w3.org/Archives/Public/...1Jul/0057.html

    It would imply you can use a combination of schema and DTD.

    I imagine this is the way you will accomplish what you are trying to do.

  6. #6
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Still not sure

    Thanks for your help so far dave. I haveone more thing I'm not sure about.

    It isn't practical for me to prevent the '³' characters from appearing in my XML file. From what I've read, entities allow things to be recognised as '&something;', but that wouldn't be the case in my situation. I want the charcter itself to be recognised.

    Am I understanding this correctly?

    The alternative is to remove the validation of my documents entirely, which I'm not too keen on...

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Kettering, Northants, England
    Posts
    56
    Entity declarations are a kind of variable, so you can reference any string (could be a standard footer or disclaimer) with another (much shorter or more convenient) one i.e.

    <?xml version="1.0"?>
    <!-- Internal DTD Subset-->
    <!DOCTYPE page [
    <!ENTITY disclaimer "We are not responsible for the content of this page in any way">
    ]>
    <!--DTD end-->
    <page>
    <content>Blah Blah Blah</content>
    <disclaim>&disclaimer;</disclaim>
    </page>

    So you might implement something like:

    <?xml version="1.0"?>
    <!-- Internal DTD Subset-->
    <!DOCTYPE juddspage [
    <!ENTITY degrees "&#248;">
    <!ENTITY slash "&#47;">
    ]>
    <!--DTD end-->
    <juddspage>
    <Unit External="kW&slash;&degrees;C" Internal="kW&slash;&degrees;C" Zero="0." Scale="1." Offset="0.">kW&slash;&degrees;C :: kW&slash;&degrees;C</Unit>
    </juddspage>

  8. #8
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    I see what you're getting at...

    but I think I haven't explained myself properly.

    What you describe is a change to the content of the XML file.
    I'm writing large files so it is not really practical to watch every character and replace '°' with '&degree;' etc.

    What I need is a way to instruct the parser (through the schema file? DTD?) that if it comes across a '³' or a '°' (for instance) when validating, not to throw a fatal error event. I really don't see why these are considered invalid characters in the first place.

    I guess I need to know if this can even be done?

    Sorry to be a pain about this!

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  9. #9

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Kettering, Northants, England
    Posts
    56
    Even & and / are invalid characters and have to defined by their ASCII Character codes, although in the case of >, <, & etc. the XML equivalents. &amp; will do fine.

    Thinking logically about it, I'm not so sure the parser doesn't like the special characters, could it be objecting to the "/" s before them?

    Dave

  10. #10
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Lost this yeterday...

    ..our internet pipe went down. I found the 'actual' problem was my encoding statement. IF I specified the encoding as UTF-8 the validation failed, if I used ISO-8859-1 (Latin-1) the validation passed.

    However, I had to hack in the XML declaration manually (hardcode it) because using the put_encoding method ddoesn't seem to work (if you don't use it, it defaults to writing the encoding as UTF-16 (even though it doesn't write in that encoding!!!), if you use put_encoding, it doesn't write any encoding statement at all, thus assuming UTF-8 and failing validation....

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

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