OZONE Asylum
Forums
CSS - DOM - XHTML - XML - XSL - XSLT
xml: when to use attributes vs text (and doctype/validation)
This page's ID:
27871
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
[quote]1) Do I need a doctype for my xml documents?[/quote] No, absolutely not. A doctype declaration is needed for validation. If you don't need to validate your document, you don't need it. [quote]After searching it looks like it's DTD, and schema. Should I focus on using schema? Or is there a disadvantage? It looks like Schema is more verbose, but is easier to use in bigger documents, and re-useable. (Or not?)[/quote] What you should choose depends. Schemas are much more expressive. If you want entitites you must use a DTD though, since schemas can't declare them. [quote]2) Is the doctype related to XSLT, or is XSLT for xml stylesheets XSL? After some reading it looks like XSL has to do with transforming the document and a stylesheet is a part of that? (And parsing/iterating xml files for output on a xhtml page?) [/quote] XSLT is a part of XSL (the other being XSL-FO but don't care about that), and is used for transforming a document (not necessarily an XML document) into another. [quote]3) How do I know when something should be an attribute, or text? (CDATA?) Some values seem like they could be either.[/quote] There is no rule, you choose. As a general rule, use attributes for things that describe some characteristics of the element, for metedata and stuff like that, and use text for things that are meant to be seen in a rendition. For example, I would mix your todo lists. <title> should be an element, but group would be better as an attribute in my opinion. [code]<!-- todo3 --> <TodoList> <item group="post"> <date year="2006" month="05" day="01"/> <title>xml attribute vs text</title> <text> Post this thread. </text> </item> <item group="foo"> <date year="2006" month="05" day="01"/> <title>bar</title> <text> Foobar. </text> </item> </TodoList>[/code] (Date could possibly be an element also). You also ask about CDATA (character data). You can mark a section as containing only CDATA. (In SGML you could declare an elements' content as CDATA, but this isn't possible in XML). CDATA sections will no be parsed for markup. For example [code]<![CDATA[not an <element/> and not an &entity-reference;]]>[/code] [small](Edited by [url=http://www.ozoneasylum.com/user/2269]HZR[/url] on 05-02-2006 11:38)[/small] [small](Edited by [url=http://www.ozoneasylum.com/user/2269]HZR[/url] on 05-02-2006 11:50)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »