XML – XSLT转换 – 产生特殊的“<? ......?>“标签
发布时间:2020-12-16 23:24:12 所属栏目:百科 来源:网络整理
导读:我正在转换一些 XML数据以适应格式为“Excel XML Spreadsheet 2003”的文档 一切正常,但我在生成结果文件的正确标题时遇到问题. 它应该基本上是以下形式: ?xml version="1.0"??mso-application progid="Excel.Sheet"?Workbook xmlns="urn:schemas-microsoft
我正在转换一些
XML数据以适应格式为“Excel XML Spreadsheet 2003”的文档
一切正常,但我在生成结果文件的正确标题时遇到问题. <?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”?>行丢失了. 我明白了<? ...>?;是一个特殊的标签 - 所以可能会质疑XSLT是如何产生的 谢谢 解决方法
有了任何输入,这个样式表:
<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" /> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |