xml元素中的html标签 [英] html tags inside xml elements

查看:93
本文介绍了xml元素中的html标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个xml项目,该项目将包含大量文件

,将由约100-150名非技术人员定期编辑

。因此,我试图让它们像

一样简单。这个项目是一个内部项目,因此只能在IE 6.x上查看
(或者如果我的公司决定使用$ x
并且因为它被部署为预先存在的结构的替换,它也不会在

网络服务器上运行(它们将是xml文件位于每个人都可以访问的共享

驱动器上。


我需要一种在元素内格式化文本的方法,这对于
来说非常简单
人尽可能输入xml数据(如果样式表是

复杂,那就'好吧我是唯一一个会看那个

和代码并没有吓到我。。我见过的最简单的编码方法

远远没有格式化的是html标签,但是xml不正确

逃避那些。我只需要< b>< u>< itags就可以了。有没有人有一个xsl样式表的任何想法都会正确显示这个



元素?


< element>< i>这< / iis< b>惊人< / b< u>元素< / u> !!< ; / element>

解决方案

* do.**@gmail.com 在comp.text.xml中写道:


>我需要一种方法来格式化元素中的文本这对于尽可能键入xml数据的人来说很简单(如果样式表很复杂,那就没关系,我是唯一一个会看到它的人
并且代码不会吓到我)。我已经看到的最简单的编码方法是格式化html标签,但是xml并没有正确地逃避这些。我只需要< b>< u>< itags就可以了。有没有人对xsl样式表有任何想法才能正确显示这个
元素?

< element>< i>这< / iis< b>惊人< ; / b将U>元素< / U> !!< /组件>



我不确定为什么逃避可能是一个问题。将上面的

转换为HTML应该是微不足道的,您只需将元素复制到

结果中(使用xsl:copy,xsl:copy-of或其他一些方法) 。

-

Bj?rn H?hrmann·mailto:bj **** @ hoehrmann.de· http://bjoern.hoehrmann.de

Weinh。海峡。 22·Telefon:+49(0)621/4309674· http://www.bjoernsworld.de

68309曼海姆·PGP Pub。 KeyID:0xA4357E78· http://www.websitedev.de/


我不知道为什么逃避可能是一个问题。将上面的


转换为HTML应该是微不足道的,您只需将元素复制到

结果中(使用xsl:copy,xsl:copy - 或其他方法)。



完全正确。如果你想要标记,请使用以XML结构表示的标记。

就个人而言,我更喜欢一些语义更有意义的东西,而不是来自XHTML(或从XHTML借来的概念)的
片段,但是XHTML将

的优点是处理起来很简单,并且不要求你教育用户你自己的标记。


-

Joe Kesselman /小心病人的愤怒。 - John Dryden


3月30日上午9:31,Joseph Kesselman< keshlam-nos ... @ comcast.net>

写道:


我不知道为什么逃避可能是一个问题。将上面的

转换为HTML应该是微不足道的,您只需将元素复制到

结果中(使用xsl:copy,xsl:copy-of或其他一些方法) 。



完全正确。如果你想要标记,请使用以XML结构表示的标记。

就个人而言,我更喜欢一些语义更有意义的东西,而不是来自XHTML(或从XHTML借来的概念)的
片段,但是XHTML将

的优点是处理起来很简单,并且不要求你教育用户你自己的标记。


-

Joe Kesselman /小心病人的愤怒。 - John Dryden



好​​吧,我想我看到了我做错了什么。我一直在使用xsl:value-of

选择!我刚刚用xsl:copy-of测试了它并修复了它。感谢

你,我花了最近3天的时间撕掉我的头发,寻找一个正好在我面前的答案。


I am working on an xml project that will contain numerous documents
which will be edited by about 100-150 non-technical people on a
regular basis. Because of this, I am trying to make it as simple as
possible for them. This project is an internal project so it will only
ever be viewed on IE 6.x (or maybe 7.x if my company ever decides to
shoot itself in the foot) and because this is being deployed as a
replacement for a pre-existing structure, it will not be running on a
web-server either (they will be the xml files sitting on a shared
drive accessed by everyone.

I need a way to format text within elements that is as simple for the
person typing the xml data as possible (if the stylesheet is
complicated, that''s ok I''m the only one that will be looking at that
and code doesn''t scare me). The simplest coding method I''ve seen so
far to put in formatting is html tags, however xml does not properly
escape those. I only need the <b><u><itags to work. Does anyone have
any ideas for an xsl stylesheet that will properly display this
element?

<element><i>This</iis an <b>amazing</b<u>element</u>!!</element>

解决方案

* do******@gmail.com wrote in comp.text.xml:

>I need a way to format text within elements that is as simple for the
person typing the xml data as possible (if the stylesheet is
complicated, that''s ok I''m the only one that will be looking at that
and code doesn''t scare me). The simplest coding method I''ve seen so
far to put in formatting is html tags, however xml does not properly
escape those. I only need the <b><u><itags to work. Does anyone have
any ideas for an xsl stylesheet that will properly display this
element?

<element><i>This</iis an <b>amazing</b<u>element</u>!!</element>

I am not sure why escaping might be a problem here. Transforming the
above into HTML should be trivial, you just copy the elements into the
result (using xsl:copy, xsl:copy-of, or some other method).
--
Bj?rn H?hrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/


I am not sure why escaping might be a problem here. Transforming the

above into HTML should be trivial, you just copy the elements into the
result (using xsl:copy, xsl:copy-of, or some other method).

Exactly. If you want markup, use markup expressed in XML structure.
Personally I would prefer something more semantically meaningful than
fragments of XHTML (or concepts borrowed from XHTML), but XHTML would
have the advantage of being trivial to process and not requiring that
you educate the user about your own markup.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden


On Mar 30, 9:31 am, Joseph Kesselman <keshlam-nos...@comcast.net>
wrote:

I am not sure why escaping might be a problem here. Transforming the
above into HTML should be trivial, you just copy the elements into the
result (using xsl:copy, xsl:copy-of, or some other method).


Exactly. If you want markup, use markup expressed in XML structure.
Personally I would prefer something more semantically meaningful than
fragments of XHTML (or concepts borrowed from XHTML), but XHTML would
have the advantage of being trivial to process and not requiring that
you educate the user about your own markup.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden

Ok, I think I see what I''m doing wrong. I''ve been using xsl:value-of
select! I just tested it with xsl:copy-of and that fixed it. Thank
you, I''ve spent the last 3 days tearing my hair out looking for an
answer that was right in front of me.


这篇关于xml元素中的html标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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