Html 要复制没有默认命名空间的子元素吗

Html 要复制没有默认命名空间的子元素吗,html,xml,Html,Xml,我正在进行XML到HTML的转换,并且我制定了xslt,在这方面,我仍然无法解决一个问题 <?xml version="1.0" encoding="UTF-8"?> <o> <abstract-short type="string"><p>Last month a high court judge ruled that, for the purposes of inheritance tax, all let property is classe

我正在进行XML到HTML的转换,并且我制定了xslt,在这方面,我仍然无法解决一个问题

<?xml version="1.0" encoding="UTF-8"?>
<o>
<abstract-short type="string"><p>Last month a high court judge ruled that, for the purposes of inheritance tax, all let property is classed the same&#x2026;</p></abstract-short>
<content type="string"><p>Last month a<em>high court</em> judgr may<a href="htpp://www.ibm.com">deal</a> with weekly (or r queries and requests then it is still classed an investment, not a business.</p><p>An appeal against this<em>decision</em> destourist industry and the role it plays in the wider South West economy.</p></content>
<created type="string">2013-02-21T23:59:00</created>
<creator class="object">
<text type="string">[creatorName]</text>
<uri type="string">[creator]</uri>
</creator>
<identifier type="string">https://www.gazettes.co.uk/content/6</identifier>
<issued type="string">2013-06-31T23:59:00</issued>
<position type="string">related pane first</position>
<relation class="array">
<e type="string">wills-and-probate</e>
</relation>
<rights type="string">[copyrightattributionURI]</rights>
<source class="object">
<text type="string">Western Morning News</text>
<uri type="string">http://www.thisisdevon.co.uk/story-18208063-detail/story.html#axzz2M0VVYB82</uri>
</source>
<subject type="string">news</subject>
<title type="string">Arguing the case for appeal over tax ruling</title>
<weight type="string">0</weight>
</o>

通过每周(或每周)的查询和请求,它仍然被归类为一项投资,而不是一项业务。

针对这一决定的上诉破坏了旅游业及其在更广泛的西南经济中所起的作用

2013-02-21T23:59:00 [创建名称] [创建者] https://www.gazettes.co.uk/content/6 2013-06-31T23:59:00 首先是相关窗格 遗嘱和遗嘱认证 [版权归属URI] 西方晨报 http://www.thisisdevon.co.uk/story-18208063-detail/story.html#axzz2M0VVYB82 新闻 为税务裁决上诉辩护 0
我的xslt代码是

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="#all">

<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>


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

<xsl:template match="o">
<xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html></xsl:text>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
  prefix="dcterms: http://purl.org/dc/terms/ dc: http://purl.org/dc/elements/1.1/ gz: https://www.gazettes.co.uk/metadata">
<xsl:apply-templates select="title"/>
</html>
</xsl:template>


<xsl:template match="o/title">
<head>
<title property="dc:title">
<xsl:attribute name="about">
<xsl:value-of select="./parent::o/child::identifier"/>
</xsl:attribute>
<xsl:apply-templates/>
</title>
<meta name="dcterms.format" content="application/xhtml+xml"/>
<xsl:apply-templates
  select="./parent::o/child::subject, ./parent::o/child::identifier, ./parent::o/child::relation, ./parent::o/child::position, ./parent::o/child::weight"
  />
</head>
<xsl:apply-templates select="./parent::o/child::created[@type='string']"/>
</xsl:template>

<!-- # Matching Meta content -->

<xsl:template match="o/created[@type='string']">
<body>
<article>
<header>
<h1 class="title">
<xsl:value-of select="./parent::o/child::title[@type='string']"/>
</h1>
</header>
<dl>
<dt>Created date</dt>
<dd property="dcterms:created">
<xsl:attribute name="content">
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:attribute name="about">
<xsl:value-of select="./parent::o/child::identifier"/>
</xsl:attribute>
<xsl:value-of select="substring-before(., 'T')"/>
</dd>
<xsl:apply-templates select="./parent::o/child::issued, ./parent::o/child::source"/>
</dl>
<xsl:apply-templates
select="./parent::o/child::abstract-short, ./parent::o/child::abstract-long, ./parent::o/child::content"
/>
</article>
</body>
</xsl:template>


<xsl:template match="o/subject">
<meta name="dcterms.subject">
<xsl:attribute name="content">
<xsl:apply-templates/>
</xsl:attribute>
</meta>
</xsl:template>

<xsl:template match="o/identifier">
<meta name="dcterms.identifier">
<xsl:attribute name="content">
<xsl:apply-templates/>
</xsl:attribute>
</meta>
</xsl:template>

<xsl:template match="o/relation/e">
<meta name="dcterms.relation">
<xsl:attribute name="content">
<xsl:apply-templates/>
</xsl:attribute>
<xsl:attribute name="scheme">
<xsl:value-of select="'isPartOf'"/>
</xsl:attribute>
</meta>
</xsl:template>

<xsl:template match="o/position">
<meta name="gz.position">
<xsl:attribute name="content">
<xsl:apply-templates/>
</xsl:attribute>
</meta>
</xsl:template>

<xsl:template match="o/weight">
<meta name="gz.weight">
<xsl:attribute name="content">
<xsl:apply-templates/>
</xsl:attribute>
</meta>
</xsl:template>


<xsl:template match="o/issued">
<dt>Publication date</dt>
<dd property="dcterms:issued">
<xsl:attribute name="content">
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:attribute name="about">
<xsl:value-of select="./parent::o/child::identifier"/>
</xsl:attribute>
<xsl:value-of select="substring-before(., 'T')"/>
</dd>
</xsl:template>

<xsl:template match="o/source">
<dt>Source</dt>
<dd property="dc:source">
<xsl:attribute name="content">
<xsl:value-of select="./uri[@type='string']"/>
</xsl:attribute>
<xsl:attribute name="about">
<xsl:value-of select="./parent::o/child::identifier"/>
</xsl:attribute>
<xsl:value-of select="./text[@type='string']"/>
</dd>
</xsl:template>

<!-- # Matching abstract short and long content -->

<xsl:template match="o/abstract-long">
<section class="abstract-long" property="dcterms:abstract">
<xsl:attribute name="about">
<xsl:value-of select="./parent::o/child::identifier"/>
</xsl:attribute>
<xsl:for-each select="./*">
<xsl:element name="{name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:for-each>
</section>
</xsl:template>

<xsl:template match="o/abstract-short">
<section class="abstract-short" property="dcterms:abstract">
<xsl:attribute name="about">
<xsl:value-of select="./parent::o/child::identifier"/>
</xsl:attribute>
<xsl:for-each select="./*">
<xsl:element name="{name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:for-each>
</section>
</xsl:template>

<!-- # Matching body content -->

<xsl:template match="o/content">
<section class="content">
<xsl:for-each select="./*">
<xsl:element name="{name()}">
<xsl:for-each select="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:for-each>
</section>
</xsl:template>
<xsl:template match="o/rights"></xsl:template>
<xsl:template match="o/creator"></xsl:template>
</xsl:stylesheet>

!DOCTYPE html>
创建日期
出版日期
来源

但是,在这里,我的问题是,我没有从模板
xsl:template match=“o/content”
中获得任何子元素,例如
em
a
。我在这方面犯了什么错误。请解释。提前感谢。

如果您只想复制
的所有子元素,请将
更改为:

<xsl:template match="o/content">
  <section class="content">
    <xsl:copy-of select="node()"/>
  </section>
</xsl:template>