阅读内容 

XML介绍系列(6)

[日期:2005-04-12] 来源:中国站长学院  作者:风未起时 [字体: ]
系列之十二:格式化XML(一)

使用JavaScript格式化XML文档
你如果要想把XML文档中的数据显示在HTML页面中,
你可以使用JavaScript来导入数据,
你要想看到XMLHTML之间是如何互补的话,可以
比较这个XML文档(note.xml)和这个HTML文档(note.htm使用了JavaScript
XML中读出数据然后显示在HTML中)
文件代码如下:
note.XML


Tove
Jani
Reminder
Don't forget me this weekend!


note.htm





<a href="http://www.blue1000.com/bkhtml/c22/" title="HTML/JavaScript教程">HTML</a> using <a href="http://www.blue1000.com/bkhtml/c21/" title="XML教程">XML</a> data




Refsnes Data Internal Note



To:




From:













翻译:Batman
系列之十三:格式化XML(二)
使用CSS格式化XML
下面来示范如何使用CSS文件来格式化XML文件
shakespeare.XML




All's Well That Ends Well
all_well.XML

Dramatis Personae
KING OF FRANCE
DUKE OF FLORENCE
BERTRAM, Count of Rousillon.
LAFEU, an old lord.
PAROLLES, a follower of Bertram.

Steward
Clown
servants to the Countess of Rousillon.

A Page.
COUNTESS OF ROUSILLON, mother to Bertram.
HELENA, a gentlewoman protected by the Countess.
An old Widow of Florence.
DIANA, daughter to the Widow.

VIOLENTA
MARIANA
neighbours and friends to the Widow.

Lords, officers, Soldiers, &c., French and Florentine.




As You Like It
as_you.XML

Dramatis Personae

DUKE SENIOR, living in banishment.
DUKE FREDERICK, his brother, an usurper of his dominions.


AMIENS
JAQUES
lords attending on the banished duke.


LE BEAU, a courtier attending upon Frederick.
CHARLES, wrestler to Frederick.


OLIVER
JAQUES
ORLANDO
sons of Sir Rowland de Boys.




ADAM
DENNIS
servants to Oliver.


TOUCHSTONE, a clown.
SIR OLIVER MARTEXT, a vicar.


CORIN
SILVIUS
shepherds.


WILLIAM, a country fellow in love with Audrey.
A person representing HYMEN.
ROSALIND, daughter to the banished duke.
CELIA, daughter to Frederick.
PHEBE, a shepherdess.
AUDREY, a country wench.
Lords, pages, and attendants, &c.





A Midsummer Night's Dream
dream.XML

Dramatis Personae

THESEUS, Duke of Athens.
EGEUS, father to Hermia.


LYSANDER
DEMETRIUS
in love with Hermia.


PHILOSTRATE, master of the revels to Theseus.
QUINCE, a carpenter.
SNUG, a joiner.
BOTTOM, a weaver.
FLUTE, a bellows-mender.
SNOUT, a tinker.
STARVELING, a tailor.
HIPPOLYTA, queen of the Amazons, betrothed to Theseus.
HERMIA, daughter to Egeus, in love with Lysander.
HELENA, in love with Demetrius.
OBERON, king of the fairies.
TITANIA, queen of the fairies.
PUCK, or Robin Goodfellow.


PEASEBLOSSOM
COBWEB
MOTH
MUSTARDSEED
fairies.


Other fairies attending their King and Queen.
Attendants on Theseus and Hippolyta.




The Tragedy of Hamlet, Prince of Denmark
hamlet.XML

Dramatis Personae

CLAUDIUS, king of Denmark.
HAMLET, son to the late, and nephew to the present king.
POLONIUS, lord chamberlain.
HORATIO, friend to Hamlet.
LAERTES, son to Polonius.
LUCIANUS, nephew to the king.


VOLTIMAND
CORNELIUS
ROSENCRANTZ
GUILDENSTERN
OSRIC
courtiers.


A Gentleman
A Priest.


MARCELLUS
BERNARDO
officers.


FRANCISCO, a soldier.
REYNALDO, servant to Polonius.
Players.
Two Clowns, grave-diggers.
FORTINBRAS, prince of Norway.
A Captain.
English Ambassadors.
GERTRUDE, queen of Denmark, and mother to Hamlet.
OPHELIA, daughter to Polonius.
Lords, Ladies, officers, Soldiers, Sailors, Messengers, and other Attendants.
Ghost of Hamlet's Father.





The Life of Henry the Fifth
hen_v.XML

Dramatis Personae

KING HENRY, the Fifth.


DUKE OF GLOUCESTER
DUKE OF BEDFORD
brothers to the King.


DUKE OF EXETER, uncle to the King.
DUKE OF YORK, cousin to the King.
EARL OF SALISBURY
EARL OF WESTMORELAND
EARL OF WARWICK
BISHOP OF CANTERBURY
BISHOP OF ELY
EARL OF CAMBRIDGE
LORD SCROOP
SIR THOMAS GREY


SIR THOMAS ERPINGHAM
GOWER
FLUELLEN
MACMORRIS
JAMY
officers in King Henry's army.




BATES
COURT
WILLIAMS
soldiers in the same.


PISTOL
NYM
BARDOLPH
Boy
A Herald.
CHARLES the Sixth, King of France.
LEWIS, the Dauphin.
DUKE OF BURGUNDY
DUKE OF ORLEANS
DUKE OF BOURBON
The Constable of France.


RAMBURES
GRANDPRE
French Lords.


GOVERNOR, of Harfleur.
MONTJOY, a French Herald.
Ambassadors to the King of England.
ISABEL, Queen of France.
KATHARINE, daughter to Charles and Isabel.
ALICE, a lady attending on her.
Hostess of a tavern in Eastcheap formerly Mistress Quickly, and now married to Pistol.
Lords, Ladies, officers, Soldiers, Citizens, Messengers, and Attendants. Chorus.





The Tragedy of King Lear
lear.XML


Dramatis Personae

LEAR, king of Britain
KING OF FRANCE
DUKE OF BURGUNDY
DUKE OF CORNWALL
DUKE OF ALBANY
EARL OF KENT
EARL OF GLOUCESTER
EDGAR, son to Gloucester.
EDMUND, bastard son to Gloucester.
CURAN, a courtier.
Old Man, tenant to Gloucester.
Doctor
Fool
OSWALD, steward to Goneril.
A Captain employed by Edmund.
Gentleman attendant on Cordelia.
A Herald.
Servants to Cornwall.


GONERIL
REGAN
CORDELIA
daughters to Lear.


Knights of Lear's train, Captains, Messengers, Soldiers, and Attendants





The Tragedy of Macbeth
macbeth.XML


Dramatis Personae

DUNCAN, king of Scotland.


MALCOLM
DONALBAIN
his sons.




MACBETH
BANQUO
generals of the king's army.




MACDUFF
LENNOX
ROSS
MENTEITH
ANGUS
CAITHNESS
noblemen of Scotland.


FLEANCE, son to Banquo.
SIWARD, Earl of Northumberland, general of the English forces.
YOUNG SIWARD, his son.
SEYTON, an officer attending on Macbeth.
Boy, son to Macduff.
An English Doctor.
A Scotch Doctor.
A Soldier.
A Porter.
An Old Man.
LADY MACBETH
LADY MACDUFF
Gentlewoman attending on Lady Macbeth.
HECATE
Three Witches.
Apparitions.
Lords, Gentlemen, officers, Soldiers, Murderers, Attendants, and Messengers.





The Tragedy of Richard the Third
rich_iii.XML


Dramatis Personae

KING EDWARD The Fourth


EDWARD, Prince of Wales, afterwards King Edward V.
RICHARD, Duke of York
sons to the King.




GEORGE, Duke of Clarence
RICHARD, Duke of Gloucester, afterwards King Richard III.
brothers to the King.


A young son of Clarence.
HENRY, Earl of Richmond, afterwards King Henry VII.
CARDINAL BOURCHIER, Archbishop of Canterbury.
THOMAS ROTHERHAM, Archbishop of York.
JOHN MORTON, Bishop of Ely.
DUKE of BUCKINGHAM
DUKE of NORFOLK
EARL of SURREY, His son.
EARL RIVERS, Brother to Elizabeth.


MARQUIS OF DORSET
LORD GREY
Sons to Elizabeth.


EARL of OXFORD
LORD HASTINGS
LORD STANLEY, Called also EARL of DERBY.
LORD LOVEL
SIR THOMAS VAUGHAN
SIR RICHARD RATCLIFF
SIR WILLIAM CATESBY
SIR JAMES TYRREL
SIR JAMES BLOUNT
SIR WALTER HERBERT
SIR ROBERT BRAKENBURY, Lieutenant of the Tower.
CHRISTOPHER URSWICK, A priest.
Another Priest.


TRESSEL
BERKELEY
Gentlemen attending on the Lady Anne.


Lord Mayor of London.
Sheriff of Wiltshire.
ELIZABETH, Queen to King Edward IV.
MARGARET, Widow of King Henry VI.
DUCHESS of YORK, Mother to King Edward IV.
LADY ANNE, Widow of Edward Prince of Wales, son to King Henry VI; afterwards married to Richard.
A young Daughter of Clarence [MARGARET PLANTAGENET]
Ghosts of those murdered by Richard III., Lords and other Attendants; a Pursuivant Scrivener, Citizens, Murderers, Messengers Soldiers, &c.





The Tempest
tempest.XML


Dramatis Personae

ALONSO, King of Naples.
SEBASTIAN, his brother.
PROSPERO, the right Duke of Milan.
ANTONIO, his brother, the usurping Duke of Milan.
FERDINAND, son to the King of Naples.
GONZALO, an honest old Counsellor.


ADRIAN
FRANCISCO
Lords.


CALIBAN, a savage and deformed Slave.
TRINCULO, a Jester.
STEPHANO, a drunken Butler.
Master of a Ship.
Boatswain.
Mariners.
MIRANDA, daughter to Prospero.
ARIEL, an airy Spirit.


IRIS
CERES
JUNO
Nymphs
Reapers
presented by Spirits.


Other Spirits attending on Prospero.






格式化用的CSS文件如下:shakespeare.css
PLAY
{
BACKGROUND-COLOR: white;
WIDTH: 100%
}
TITLE
{
COLOR: #000088;
DISPLAY: block;
FONT-SIZE: 24pt;
MARGIN-BOTTOM: 12pt;
MARGIN-LEFT: 24pt;
MARGIN-TOP: 12pt
}
FM
{
DISPLAY: block;
FONT-SIZE: 10pt;
MARGIN-BOTTOM: 18pt;
MARGIN-TOP: 18pt
}
P
{
DISPLAY: block
}
PERSONAE
{
}
PGROUP
{
DISPLAY: block;
MARGIN-BOTTOM: 18pt;
MARGIN-TOP: 18pt
}
PERSONA
{
COLOR: #000022;
DISPLAY: block;
FONT-SIZE: 14pt;
MARGIN-LEFT: 5pt
}
GRPDESCR
{
COLOR: #440000;
DISPLAY: block;
FONT-SIZE: 14pt;
MARGIN-LEFT: 24pt
}
SCNDESCR
{
COLOR: #004400;
DISPLAY: block;
FONT-SIZE: 14pt;
MARGIN-BOTTOM: 12pt;
MARGIN-LEFT: 12pt;
MARGIN-TOP: 6pt
}
PLAYSUBT
{
COLOR: #880000;
DISPLAY: block;
FONT-SIZE: 36pt;
MARGIN-BOTTOM: 18pt;
MARGIN-TOP: 36pt;
TEXT-ALIGN: center
}
INDUCT
{
DISPLAY: block;
FONT-STYLE: italic
}
ACT
{
}
SCENE
{
}
PROLOGUE
{
DISPLAY: block;
FONT-STYLE: italic
}
EPILOGUE
{
DISPLAY: block;
FONT-STYLE: italic
}
SPEECH
{
DISPLAY: block
}
SPEAKER
{
COLOR: #880000;
DISPLAY: block;
FONT-SIZE: 14pt;
MARGIN-LEFT: 12pt;
MARGIN-TOP: 12pt
}
LINE
{
DISPLAY: block;
FONT-SIZE: 12pt;
MARGIN-LEFT: 24pt
}
STAGEDIR
{
COLOR: #004400;
DISPLAY: block;
FONT-SIZE: 14pt;
MARGIN-BOTTOM: 12pt;
MARGIN-LEFT: 12pt;
MARGIN-TOP: 6pt
}
SUBTITLE
{
}
SUBHEAD
{
}
path
{
COLOR: green;
DISPLAY: block;
FONT-SIZE: 14pt;
FONT-STYLE: italic;
MARGIN-LEFT: 12pt
}

看上去好象使用CSS来显示XML很不错的,但是将来肯定是要使用XSL来显示XML文件的。

阅读:
录入:

推荐 】 【 打印
上一篇:XML介绍系列(5)
下一篇:XML介绍系列(7)
相关新闻      
本文评论       全部评论
发表评论
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款


点评: 字数
姓名:
Advertisement
内容查询


Advertisement