XML起始元素未在输出xml中打印 [英] XML start element is not printing in the output xml
本文介绍了XML起始元素未在输出xml中打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的xml输出看起来像这样
My xml output looks like this
<Envelope>
<Header>
<TimeStamp>2012-08-17T12:04:21-05:00</TimeStamp>
</Header>
</Envelope>
但是我的文件没有开始元素
But my file does not have the start element
xml version="1.0" encoding="utf-8"?>
在我的代码中,我已经给出了
in my code i have given
xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
如何使用xslt 2.0显示起始元素
How do i display the start element using xslt 2.0
推荐答案
test1.xml:
test1.xml:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test1-style.xslt"?>
<Envelope>
<Header>
<TimeStamp>2012-08-17T12:04:21-05:00</TimeStamp>
</Header>
</Envelope>
test1-style.xslt:
test1-style.xslt:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<xsl:template match="Envelope/Header">
<h1><xsl:apply-templates/></h1>
</xsl:template>
<xsl:template match="Envelope/Header/TimeStamp">
<b><xsl:value-of select="."/></b>
</xsl:template>
<xsl:template match="/"> <!-- Envelope -->
<html lang="en">
<head>
<title>Test sample</title>
<style>
h1 { color: red; }
</style>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
输出:
2012-08-17T12:04:21-05:00
Output:
2012-08-17T12:04:21-05:00
这篇关于XML起始元素未在输出xml中打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文