XML - XSLT 转换 - 产生特殊的“<?...>>"标签 [英] XML - XSLT Transformation - producing special "<? ... ?>" tag
本文介绍了XML - XSLT 转换 - 产生特殊的“<?...>>"标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在转换一些 XML 数据以适应格式为Excel XML Spreadsheet 2003"的文档
I am transforming some XML data to fit into document that is in a format of"Excel XML Spreadsheet 2003"
一切正常,但我在生成结果文件的正确标头时遇到问题.它基本上应该是一种形式:
It all works ok, but I have a problem with generating the proper header of the result file. It should basically be in a form of:
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<!-- end of header here and the transformation data goes below -->
<Workbook>
XSLT 文件是
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" media-type="text/xml"/>
<xsl:template match="/">
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
但在结果文件中 <?mso-application progid="Excel.Sheet"?>
行丢失.
but in the result file the <?mso-application progid="Excel.Sheet"?>
line is missing.
我明白...?>
是一个特殊的标签 - 所以可能的问题是它如何由 XSLT 生成
I understand that <? ...?>
is a special tag - so may question is how can it be produced by the XSLT
谢谢
推荐答案
对于任何输入,此样式表:
With any input, this stylesheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" media-type="text/xml"/>
<xsl:template match="/">
<xsl:processing-instruction name="mso-application">progid="Excel.Sheet"</xsl:processing-instruction>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40"/>
</xsl:template>
</xsl:stylesheet>
结果:
<?xml version="1.0" encoding="utf-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" />
这篇关于XML - XSLT 转换 - 产生特殊的“<?...>>"标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文