XML + DTD and formatting using CSS

i ama bit stuck on formatting my xml

Page 1 of 1

4 Replies - 4718 Views - Last Post: 12 October 2008 - 07:39 PM

#1 DaneAU  Icon User is offline

  • Great::Southern::Land
  • member icon

Reputation: 284
  • View blog
  • Posts: 1,617
  • Joined: 15-May 08

XML + DTD and formatting using CSS

Posted 18 September 2008 - 02:09 AM

I am not sure if this is the right section however I hope that someone can shed some light on this for me.

I have a project due tomorrow, i have basically finished it and am awaiting a reply from my lecturer on how the information is actually meant to be presented... ok below is a simple example of what is required
    Create an XML template
    Create a DTD
    Use CSS to style
So for my DTD as an example
person.dtd
	 <!ELEMENT person (name_first,name_last,personal_details+)>
   <!ELEMENT name_first   (#PCDATA)>
   <!ELEMENT name_last	(#PCDATA)>
	
	<!ELEMENT personal_datails (age,weight)>
	<!ELEMENT age (#PCDATA)>
	<!ELEMENT weight (#PCDATA)>



Then an xml file person.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="person.css"?>
<!DOCTYPE person SYSTEM "person.dtd">

<people>
	<person>	  
	<name_first>bbq</name_first>
	<name_last>D.I.C</name_last> 
	<personal_details>
		<age>20</age>
		<weight>80</weight>
		</personal_details>
	</person>

	<person>
	<name_first>John</name_first>
	<name_last>Smith</name_last>
		<personal_details>
			<age>50</age>
			<weight>80</weight>
		</personal_details>
	</person>
</people>



Then in my .css file called person.css I have the following
person
{
	font-size: 16pt;
	font-family : Arial Black;
	background-color: #dddddd;
	width: 70%;
	text-align: center;
	border : solid 2px;
}



The problem lies in that i have many other DTD all under person, not only do i have name i have things like
personal_details which in that has age, height, weight etc..

When i open the XML document it is rather horrible to look at, with information all being in. How can i use CSS to format my xml, as in like have each thing on a new line... The above is an example and it hasn't been through a validator, however yeah, i cannot find anywhere how to format my xml document using css. As far as i know i cannot use XSL either, which makes it a pain. So the main thing is, it all comes out in a single grey box, all on one line
I would like to have it in the format

Page Title

=================
bbq D.I.C
Age : 20
Weight : 80
=================
John Smith
Age : 50
Weight : 80
=================
and so on...

How can i use some kind of formatting to give a title to each xml page and then format each "Person(s)" details to appear a little nicer on the eyes with some headings of what each is ?

Also, IE displays each person and there details vertically, whilse opera, netscape and firefox display them horizontally ? Any ideas how to overcome this.

IE :
bbq
JohnSmith

others :
bbq | JohnSmith

etc...

This post has been edited by bbq: 18 September 2008 - 02:46 AM


Is This A Good Question/Topic? 0
  • +

Replies To: XML + DTD and formatting using CSS

#2 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1377
  • View blog
  • Posts: 10,951
  • Joined: 06-February 08

Re: XML + DTD and formatting using CSS

Posted 18 September 2008 - 05:26 AM

Moved to HTML & CSS. :)
Was This Post Helpful? 0
  • +
  • -

#3 DaneAU  Icon User is offline

  • Great::Southern::Land
  • member icon

Reputation: 284
  • View blog
  • Posts: 1,617
  • Joined: 15-May 08

Re: XML + DTD and formatting using CSS

Posted 18 September 2008 - 09:32 AM

Ah thanks, wasn't sure if this was the right place or not :ph34r:
Was This Post Helpful? 0
  • +
  • -

#5 Logomachist  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 74
  • Joined: 10-March 08

Re: XML + DTD and formatting using CSS

Posted 11 October 2008 - 11:24 AM

What you want are the CSS properties/values "display: block;" and "content:"

"display: block;" puts gives an element a line or lines all by itself.

"content:", along with the pseudo-elements ":before" and "after" allow you to add content before and after elements. Using these you can add lines made up of "=" and add labels before the age and weight elements. See attached file for examples.

Attached File(s)

  • Attached File  delme.xml (1.43K)
    Number of downloads: 178

Was This Post Helpful? 1
  • +
  • -

#6 DaneAU  Icon User is offline

  • Great::Southern::Land
  • member icon

Reputation: 284
  • View blog
  • Posts: 1,617
  • Joined: 15-May 08

Re: XML + DTD and formatting using CSS

Posted 12 October 2008 - 07:39 PM

Ah nice yea that is what i am after actually.. The first part of the assignment didn't require such things but yea the next stage does so thanks for the info :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1