新手 - 试图开始使用docbook [英] Novice - trying to get started with docbook

查看:77
本文介绍了新手 - 试图开始使用docbook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试XML文档。

我正在尝试开始使用docbook,这样我就可以将一套

的文档放入docbook标签中。我正在使用''XML in A

Nutshell"和DocBook The Definitive Guide,两者都已经过时了。


我有一个简单的文件解析,但是当我读到它进入了

Netscape或Konqueror,我没有得到我希望的结果。


首先,我'我不确定浏览器是否正在使用以下网址引用dtd文件:
http://www.oasis-open.org/docbook/xm...2/docbookx.dtd


我在每个浏览器中打开一个本地文件''book.xml''。

这个文件应该是读取本地文件,' chap1.xml。我是

附上两个文件。

在网景中我得到以下结果:


_________________________________________

此XML文件似乎没有与之关联的任何样式信息

。文档树如下所示。


- < book>

< title>我的第一本书< / title>

< chapter>第2章< / chapter>

< chapter>第3章< / chapter>

< / book>


_________________________________________

在Konqueror中我得到以下结果:


_________________________________________

第2章第3章

_________________________________________


Netscape只显示xml标签,暗示它确实不知道如何解释它们。 Konqueror似乎已经消化了标签,暗示它们是合法的标签,而且b $ b也意味着它读取了dtd。但是''章节'没有

格式,所以这意味着Konqueror

并没有真正处理dtd。


我的问题如下:


如何知道docbookx.dtd是否真正被读取?


我需要使用不同的xml处理器?

Jim Anderson

解决方案

2月7日星期二2006 09:55:29 GMT,Jim Anderson< ez *** @ ieee.org>写道:


扔掉你的XML Nutshell指南。我现在已经很久没有读过O''Reilly的价值

了(可悲) - 而且肯定不是一个。 DocBook

不是很好,但它是唯一的(?)书籍


我会推荐一个不错的XML / XSLT入门书但实际上我被困了一个


迈克尔凯的XSLT书仍然是最好的吗?当然不是现在

首先,我不确定浏览器是否正在使用URL获取引用的dtd文件:
http://www.oasis-open.org/docbook/ xm ... 2 / docbookx.dtd

他们不是。 XML处理器(在极少数情况下除外)无法使用

DTD。


XML不是SGML。 XML基本上是有限的,但很简单,并且使用了更好的开发和更好的集成DOM接口(一个代表解析文档的
编程API)。对于SGML,DTD

是解析所有文档的关键部分 - 对于XML来说,它仅仅是用于编写转换的XSLT样式表的人类的文档。
将你的XML变成更有用的东西。


幸运的是,对于DocBook你需要写很少的东西,因为

大部分已经可用 - 试试Norman Walsh的XSLT库。

我在每个浏览器中打开一个本地文件''book.xml'。
这个文件应该是读取本地文件文件,''chap1.xml''。我是
附上这两个文件。


不要附加,上传和发布网址。对于很多这种调试

我们需要看到它的实时和真实。

Netscape只显示xml标签,暗示它确实
不知道如何解释它们。


(实际上它可能确实解释了它们,但是以香草的默认方式

方式)


你需要什么这里要做的是提供一些XSLT将XML转换为HTML,然后通过浏览器查看。将

样式表附加到XML文档本身,或者将其转换为服务器端,并且

提供结果HTML。网页搜索肯定会出现教程 -

这是非常古老的帽子。


另外看一下使用XSL制作PDF等:FO和Apache FOP。这也需要获得XSLT知识(或下载现有工作),但是学习BLSL比学习XSLT更麻烦,而且可能值得关注。

我是否需要使用不同的xml处理器?




这是您的语言平台的问题,而不是您的文档格式。

周围有许多数量,大多数都可以使用。 XML / XSLT是令人惊讶的独立平台,并且它真的不是那么难以交换处理器(如果你对大多数人有经验,这真是太棒了/>
软件开发!)


如果你真的遇到困难,Manning的'Ajax in Action"虽然看起来似乎无关紧要,所以书不会伤害




Andy Dingley写道:

Michael Kay的XSLT书仍然是最好的吗?肯定不是到现在为止


它仍然是我见过的最好的一种我对该语言的密集和权威

描述。学习

可能不是最简单的事情,但如果你不擅长阅读正式规范(即使你是)。


但我一段时间没有看书,所以肯定会有一些东西可能会有什么东西那里更好。

他们不是。 XML处理器(极少数情况除外)对DTD没有任何作用。


不完全正确。一些应用程序根据他们的

DTD验证XML文档;许多人不会。


DTD(或XML Schema)是对可接受的哪种类型的b $ b文件的正式描述,并充当"合同"工具之间或

写文档的人和阅读它的工具或人。对于

人类非正式使用通常是不需要的,所以浏览器通常不会验证,除非明确告知这样做。但是,如果你想要设计机器对机器交易,你真的想确定购买订单文件中的b $ b是什么意思。或数据库查询

交易,以确保每个人都同意如何创建和阅读这些消息




对于DocBook,验证可以帮助确保文档正确写入,因此将得到正确处理。但是你可能没有它就可以离开。

幸运的是,对于DocBook你需要写很少的东西,因为
大多数已经可用 - 试试Norman Walsh的XSLT库。


资源充足。另一方面,DocBook可以合法地以多种不同的方式呈现/处理/过滤,以及不同的b
目标表示,因此这些只是一个可能的起点。 br />
它们周围有任意数量且大多数都可用。 XML / XSLT令人惊讶地与平台无关,而且切换处理器真的不那么难(如果您对大多数软件开发经验丰富,这是非常棒的事情!)




W3C以及那些完成这些

详细信息的实际工作的成员,花费了大量的工时来实现这一目标确保

XML和围绕它构建的规格达到了良好的甜蜜点。一般性,

有用性,可实现性和可移植性。我直接和非正式地参与了一些

;

质量和相关人员的认真态度给我留下了深刻的印象,他们愿意听取其他观点。


XML和相关的规范确实有一些瑕疵;有些事我很有信心

如果我们再次这样做的话,我们会做的就是我们已经学到的了。

。但是对于渐进式构建的东西,并行的
,有时候从理想序列向后,它是非常合理的!


Jim Anderson写道:

这是我第一次尝试XML文档。
我正在尝试使用docbook,所以我可以将一套文档放入docbook标签。




所有你需要的是一个xml-stylesheet处理指令在
$ b $的顶部b你的文档,所以浏览器可以获得如何渲染你的XML的说明:


<?xml-stylesheet type =" text / xsl" ;

href =" ... / docbook-xsl-1.69.1 / html / docbook.xsl"?>


从下载样式表

http://docbook.sourceforge.net/projects / xsl /


ht

-

Henry S. Thompson,爱丁堡大学HCRC语言技术组

W3C团队的半场成员

2 Buccleuch Place,爱丁堡EH8 9LW,苏格兰 - ( 44)131 650-4440

传真:(44)131 650-4587,电子邮件: ht @ inf。 ed.ac.uk

网址: http://www.ltg.ed.ac.uk/~ht/

[邮件真的来自我_always_有这个.sig - 没有它的邮件是伪造的垃圾邮件]


This is my first attempt at XML documentation.
I''m trying to get started with docbook so I can put a set
of documentation into docbook tags. I''m using ''XML In A
Nutshell" and "DocBook The Definitive Guide", both of which
are a bit outdated already.

I have a simple file that parses, but when I read it into
Netscape or Konqueror, I do not get the results that I would
hope for.

First, I''m not sure that the browsers are picking up
the referenced dtd file with the URL:
http://www.oasis-open.org/docbook/xm...2/docbookx.dtd

I''m opening the a local file, ''book.xml'' in each of the browsers.
This file should be reading the local file, ''chap1.xml''. I''m
attaching both files.
In netscape I get the following results:

_________________________________________
This XML file does not appear to have any style information
associated with it. The document tree is shown below.

- <book>
<title>My First Book</title>
<chapter>Chapter 2</chapter>
<chapter>Chapter 3</chapter>
</book>

_________________________________________
In Konqueror I get these results:

_________________________________________
Chapter 2Chapter 3
_________________________________________

Netscape simply displays the xml tags, implying it did
not know how to interpret them. Konqueror seems to have
digested the tags, implying they are legitimate tags and
also implying that it read the dtd. But there is no
formatting for the ''chapters'', so this implys Konqueror
did not really handle the dtd.

My questions are as follows:

How do I know if the docbookx.dtd is actually being read?

Do I need to use a different xml processor?

Jim Anderson

解决方案

On Tue, 07 Feb 2006 09:55:29 GMT, Jim Anderson <ez***@ieee.org> wrote:

Throw away your XML Nutshell guide. I haven''t read an O''Reilly worth
having in years now (sadly) - and that''s certainly not one. DocBook
isn''t great, but it''s the only (?) book around

I''d recommend a decent XML / XSLT primer but I''m actually stuck for one

Is Michael Kay''s XSLT book still the best around? Surely not by now

First, I''m not sure that the browsers are picking up
the referenced dtd file with the URL:
http://www.oasis-open.org/docbook/xm...2/docbookx.dtd
They aren''t. XML processors (except in rare cases) do nothing with
DTDs.

XML is not SGML. XML is basically limited, but simple, and with a
rather better developed and better integrated DOM interface (a
programming API that represents the parsed document). For SGML the DTD
is a key part of parsing all documents - for XML it''s just
documentation for the humans writing the XSLT stylesheets that transform
your XML into something more useful.

Fortunately for DocBook you need to write very little of this stuff as
most is already available - try Norman Walsh''s XSLT libraries.
I''m opening the a local file, ''book.xml'' in each of the browsers.
This file should be reading the local file, ''chap1.xml''. I''m
attaching both files.
Don''t attach, upload and post URLs. For a lot of this sort of debugging
we need to see it live and for real.
Netscape simply displays the xml tags, implying it did
not know how to interpret them.
(Actually it probably did interpret them, but in a vanilla default
manner)

What you need to do here is to provide some XSLT to transform the XML
into HTML, then look at that through the browser. Either attach the
stylesheet to the XML document itself, or transform it server-side and
serve the resultant HTML. Web searching will surely turn up tutorials -
this is very old hat by now.

Also look at making PDF etc. by use of XSL:FO and Apache FOP. This also
need XSLT knowledge (or download existing work) but it''s less trouble to
learn than XSLT is and probably worth looking at.
Do I need to use a different xml processor?



This is a question for your language platform, not your document format.
There are any number of them around and most are usable. XML / XSLT is
surprisingly platform independent and it''s really not that hard to
switch processors (this is amazing stuff if you''re experienced with most
software development!)

If you really get stuck, Manning''s "Ajax in Action" book wouldn''t hurt
to read, irrelevant though it might seem at present.


Andy Dingley wrote:

Is Michael Kay''s XSLT book still the best around? Surely not by now
It''s still the best one I''ve seen for an intensive and authoritative
description of the language. Might not be the easiest thing to learn
from, but definitely worth having on hand as a reference if you aren''t
good at reading formal specifications (and even if you are).

But I haven''t been looking at books in a while, so it''s certainly
possible there''s something better out there.
They aren''t. XML processors (except in rare cases) do nothing with
DTDs.
Not quite true. Some applications validate XML documents against their
DTD; many don''t.

A DTD (or an XML Schema) is a formal description of what kinds of
documents are acceptable, and acts as a "contract" between the tool or
person writing the document and the tool or person reading it. For
informal use by humans that often isn''t needed, so browsers generally
don''t validate unless explicitly told to do so. But if you''re trying to
design machine-to-machine transactions, you really do want to nail down
what you mean by "a purchase order document" or "a database query
transaction", to make sure everyone agrees on how to create and read
those messages.

In the case of DocBook, validation can help ensure that the document is
written correctly and hence will be processed correctly. But you may be
able to get away without it.
Fortunately for DocBook you need to write very little of this stuff as
most is already available - try Norman Walsh''s XSLT libraries.
Good resource. On the other hand, DocBook can be legitimately
rendered/processed/filtered in many different ways and to different
target representations, so those are just one possible starting point.
There are any number of them around and most are usable. XML / XSLT is
surprisingly platform independent and it''s really not that hard to
switch processors (this is amazing stuff if you''re experienced with most
software development!)



The W3C, and the members who did the actual work of thrashing out these
details, put a lot of man-hours into achieving exactly that, making sure
XML and the specs built around it hit good "sweet spots" of generality,
usefulness, implementability and portability. I was involved in some of
that, both directly and informally; I was generally impressed by the
quality and seriousness of the people involved, and their willingness to
listen to other points of view.

XML and the related specs do have some warts; there are things I''m sure
we''d do differently if we were doing it all again with the benefit of
what we''ve learned. But for something that was built up incrementally,
in parallel, and sometimes backward from the ideal sequence, it''s
surprisingly reasonable!


Jim Anderson writes:

This is my first attempt at XML documentation.
I''m trying to get started with docbook so I can put a set
of documentation into docbook tags.



All you need is an xml-stylesheet processing instruction at the top of
your document, so the browser can get instructions on how to render
your XML:

<?xml-stylesheet type="text/xsl"
href=".../docbook-xsl-1.69.1/html/docbook.xsl"?>

Download the stylesheets from

http://docbook.sourceforge.net/projects/xsl/

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]


这篇关于新手 - 试图开始使用docbook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆