XML和XSL [英] XML and XSL

查看:53
本文介绍了XML和XSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




大家好


我很难用XML。并不是我不理解

的概念,但我真的觉得如果不是这样的话就不会那么难了。
浏览器。


使用下面的文件,IE给出了预期的结果(''预期''我的意思是,它

给出了我想要的结果) :


Mark

Peter

Bob

但是,Firefox只列出了Bob。


如果有人能告诉我原因,我会非常感激。


我的目标是生成基于XML的图形(显示jpg图像和数据)和b / b
数据库驱动的网站,在最新版本的Firefox和IE 6 SP1版本中都能正常运行。我不现实吗?是否有任何XML技术可以在两种浏览器中为我提供一致的结果,或者

我是不现实的?


任何我们将不胜感激!


感谢

Hal


[file1:1002people.xml]

<?xml version =" 1.0" standalone =" no"?>

<?xml-stylesheet type =" text / xsl" HREF =" 1002people.xsl" ?>


<! - 这是一个人的列表 - >

< people>

<丈夫雇用="是">

< name>标记< / name>

< age> 46< / age>

< wife>

< wname> Janet< / wname>

< age> 42< / age>

< ; /妻子>

< /丈夫>

<丈夫雇用=" No">

< name> Peter< / name>

< age> 33< / age>

< wife>

< wname> Sally< / wname>

< age> 28< / age>

< / wife>

< / husband>

<丈夫雇用=" No">

< name> Bob< / name>

< age> 38< / age>

< wife>

< wname> Annie< / wname>

< age> 23< / age>

< ; /妻子>

< /丈夫>


< / people>


[file2:1002people.xsl]

<?xml version =" 1.0"?>


< xsl:stylesheet version =" 1.0"


xmlns:xsl =" http://www.w3.org/1999/XSL/Transform">


< xsl:template match =" /">

< xsl:apply-templates />

< / xsl:template> ;


< xsl:template match ="丈夫">

< xsl:value-of select =" name" />< br />

< / xsl:template>

< / xsl:stylesheet>

解决方案

Hal写道:


使用下面的文件,IE给出了预期的结果(''预期''我的意思是,它

给出我想要的结果):


Mark

Peter

Bob


>

[file1:1002people.xml]

<?xml version =" 1.0 " standalone =" no"?>

<?xml-stylesheet type =" text / xsl" HREF =" 1002people.xsl" ?>


<! - 这是一个人的列表 - >

< people>

<丈夫雇用="是">

< name>标记< / name>

< age> 46< / age>

< wife>

< wname> Janet< / wname>

< age> 42< / age>

< ; /妻子>

< /丈夫>

<丈夫雇用=" No">

< name> Peter< / name>

< age> 33< / age>

< wife>

< wname> Sally< / wname>

< age> 28< / age>

< / wife>

< / husband>

<丈夫雇用=" No">

< name> Bob< / name>

< age> 38< / age>

< wife>

< wname> Annie< / wname>

< age> 23< / age>

< ; /妻子>

< /丈夫>

< / people>


[file2:1002people.xsl]

<?xml version =" ; 1.0"?>


< xsl:stylesheet version =" 1.0"


xmlns:xsl =" http ://www.w3.org/1999/XSL/Transform">


< xsl:template match =" /">

< xsl:apply-templates />

< / xsl:template>


< xsl:template match =" husband"> ;

< xsl:value-of select =" name" />< br />

< / xsl:template>


< / xsl:stylesheet>



试试这个:


[file2:1002people.xsl]

<?xml version =" 1.0"?>


< xsl:stylesheet version =" 1.0"


xmlns:xsl = " http://www.w3.org/1999/XSL/Transform">


< xsl:template match =" /">

< html>

< xsl:apply-templates />

< / html>

< / xsl:template>


< xsl:template match =" husband">

< xsl:value-of select =" name" />< br />

< / xsl:template>

< / xsl:stylesheet>


Hal schrieb:


使用下面的文件,IE给出了预期的结果(''expect''我的意思是,它是

给出了我想要的结果):


马克

彼得

鲍勃


但是,Firefox只列出了Bob。



Firefox只有不同的错误恢复:-)


[...]


[file2:1002people.xsl]

<?xml version =" 1.0"?>


< xsl:stylesheet version =" 1.0"


xmlns:xsl =" http://www.w3.org/1999/XSL/Transform">


< xsl:template match =" /">

< xsl:apply-templates />

< / xsl:template>


< xsl:template match ="丈夫">

< xsl:value-of select =" ;名称" />< br />

< / xsl:template>


< / xsl:stylesheet>



你必须在结果树中创建一个根元素。

-

Johannes Koch

in te domine speravi;非永久性的东西。

(Te Deum,4美分。)


Magnus - 你很美!是的,这很有效,谢谢!


我认为浏览器应该受到责备是错误的。


你有什么看法吗?关于我的另一点,但是?希望现在使用XHTML + XML + XSLT来推动互联网网站对我来说是否现实?

这些技术是否在主浏览器中得到足够的支持以允许

我和他们一起开发,而不必为了解决兼容性问题而在
中编写大量的额外代码?


我希望你可以忍受我,直到我能把它清理干净!


谢谢

Hal




Hi all

I am having a hard time with XML. It''s not that I don''t understand the
concepts, but I really feel it wouldn''t be that difficult if it wasn''t for
the browsers.

Using the files below, IE gives expected results (by ''expected'' I mean, it
gives the results that I wanted):

Mark
Peter
Bob
However, Firefox only lists Bob.

If anyone could tell me why, I would be really grateful.

My aim is to produce XML-based graphical (showing jpg images and data) and
database-driven websites that are fully functional in both the latest
version of Firefox and IE 6 SP1 onwards. Am I being unrealistic? Is there
any XML technology that can offer me consistent results in both browsers, or
am I being unrealistic?

Any thoughts would be appreciated!

With thanks
Hal

[file1: 1002people.xml]
<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="1002people.xsl" ?>

<!-- this is a list of people -->
<people>
<husband employed="Yes">
<name>Mark</name>
<age>46</age>
<wife>
<wname>Janet</wname>
<age>42</age>
</wife>
</husband>
<husband employed="No">
<name>Peter</name>
<age>33</age>
<wife>
<wname>Sally</wname>
<age>28</age>
</wife>
</husband>
<husband employed="No">
<name>Bob</name>
<age>38</age>
<wife>
<wname>Annie</wname>
<age>23</age>
</wife>
</husband>

</people>

[file2: 1002people.xsl]
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="husband">
<xsl:value-of select="name" /><br />
</xsl:template>
</xsl:stylesheet>

解决方案

Hal wrote:

Using the files below, IE gives expected results (by ''expected'' I mean, it
gives the results that I wanted):

Mark
Peter
Bob

>
[file1: 1002people.xml]
<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="1002people.xsl" ?>

<!-- this is a list of people -->
<people>
<husband employed="Yes">
<name>Mark</name>
<age>46</age>
<wife>
<wname>Janet</wname>
<age>42</age>
</wife>
</husband>
<husband employed="No">
<name>Peter</name>
<age>33</age>
<wife>
<wname>Sally</wname>
<age>28</age>
</wife>
</husband>
<husband employed="No">
<name>Bob</name>
<age>38</age>
<wife>
<wname>Annie</wname>
<age>23</age>
</wife>
</husband>

</people>

[file2: 1002people.xsl]
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="husband">
<xsl:value-of select="name" /><br />
</xsl:template>
</xsl:stylesheet>

Try this:

[file2: 1002people.xsl]
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>

<xsl:template match="husband">
<xsl:value-of select="name" /><br />
</xsl:template>
</xsl:stylesheet>


Hal schrieb:

Using the files below, IE gives expected results (by ''expected'' I mean, it
gives the results that I wanted):

Mark
Peter
Bob
However, Firefox only lists Bob.

Firefox just has a different error recovery :-)

[...]

[file2: 1002people.xsl]
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="husband">
<xsl:value-of select="name" /><br />
</xsl:template>
</xsl:stylesheet>

You have to create a root element in the result tree.
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)


Magnus - you beauty! Yes, that worked, thank you!

It was wrong of me to assume the browser was to blame.

Do you have any views about my other point, though? Is it realistic for me
to hope to use XHTML + XML + XSLT to drive Internet websites at this time?
Are these technologies supported well enough in the main browsers to allow
me to develop with them without having to write masses of extra code in
order to resolve compatibility issues?

I hope you can bear with me until I can clear this up in my head!

Thanks
Hal


这篇关于XML和XSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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