我有一个包含HTML文件的XML。我试图从xml中提取html文件,但是我收到了与标签相关的错误:
第41行第3列的错误 SXXP0003:XML解析器报告的错误:元素类型" META"必须由中止 匹配结束标记""。
如何提取HTML文件?
这是我的XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="SyncSAP_JMS"> <!-- source bod name -->
<SyncReckitt> <!-- target bod name -->
<xsl:apply-templates select="ApplicationArea"/>
<xsl:apply-templates select="DataArea"/>
</SyncReckitt>
</xsl:template>
<xsl:template match="ApplicationArea">
<ApplicationArea>
<xsl:copy-of select="*"/>
</ApplicationArea>
</xsl:template>
<xsl:template match="DataArea">
<DataArea>
<xsl:apply-templates select="Sync"/>
<xsl:apply-templates select="SAP_JMS"/>
</DataArea>
</xsl:template>
<xsl:template match="Sync"> <!-- source verb type -->
<Sync> <!-- target verb type -->
<xsl:copy-of select="*"/>
</Sync>
</xsl:template>
<xsl:template match="SAP_JMS"> <!-- source noun type -->
<Reckitt> <!-- target nound type -->
<!-- put your mappings here -->
<xsl:copy-of select="//html"/>
</Reckitt>
</xsl:template>
<xsl:template match="OptivaSAPFormat" />
</xsl:stylesheet>
这是我的xml
<OptivaSAPFormat>
<IONUNIQUEID>FASTSKU_INB</IONUNIQUEID>
<fsxml>
<FSACTIONSETSTART KEYS="FASTSKU_INB">
<KEYCODE>FASTSKU_INB</KEYCODE>
<FSACTIONSETSTARTOBJECTLIST>
<OBJ_LINE_ID>1</OBJ_LINE_ID>
<TARGET_OBJECT_KEY>FASTSKU_FIELDS</TARGET_OBJECT_KEY>
<TARGET_OBJECT_SYMBOL>PROJECT</TARGET_OBJECT_SYMBOL>
<FSACTIONSETSTARTPARAM>
<SRVROW_ID>1</SRVROW_ID>
<PARAM_CODE>C_GLOBAL_ITEM_NUMBER</PARAM_CODE>
<PVALUE>test - Global Item Number</PVALUE>
</FSACTIONSETSTARTPARAM>
</FSACTIONSETSTARTOBJECTLIST>
</FSACTIONSETSTART>
</fsxml>
<html xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ns0="urn:ReckittBenckiser.com:GBL:TRACKWISE:Material">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<STYLE type="text/css">
.datagrid table { border-collapse: collapse; text-align: left; width: 100%; } .datagrid {font: normal 12px/150% Arial, Helvetica, sans-serif; background: #fff; overflow: hidden; border: 1px solid #006699; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }.datagrid table td, .datagrid table th { padding: 3px 10px; }.datagrid table thead th {background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #006699), color-stop(1, #00557F) );background:-moz-linear-gradient( center top, #006699 5%, #00557F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#006699', endColorstr='#00557F');background-color:#006699; color:#FFFFFF; font-size: 15px; font-weight: bold; border-left: 1px solid #0070A8; } .datagrid table thead th:first-child { border: none; }.datagrid table tbody td { color: #00496B; border-left: 1px solid ;font-size: 12px;font-weight: normal; }.datagrid table tbody .alt td { background: #E1EEF4; color: #00496B; }.datagrid table tbody td:first-child { border-left: none; }.datagrid table tbody tr:last-child td { border-bottom: none; }.datagrid table tfoot td div { border-top: 1px solid #006699;background: #E1EEF4;} .datagrid table tfoot td { padding: 0; font-size: 12px } .datagrid table tfoot td div{ padding: 2px; }.datagrid table tfoot td ul { margin: 0; padding:0; list-style: none; text-align: right; }.datagrid table tfoot li { display: inline; }.datagrid table tfoot li a { text-decoration: none; display: inline-block; padding: 2px 8px; margin: 1px;color: #FFFFFF;border: 1px solid #006699;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #006699), color-stop(1, #00557F) );background:-moz-linear-gradient( center top, #006699 5%, #00557F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#006699', endColorstr='#00557F');background-color:#006699; }.datagrid table tfoot ul.active, .datagrid table tfoot ul a:hover { text-decoration: none;border-color: #006699; color: #FFFFFF; background: none; background-color:#00557F;}div.dhtmlx_window_active, div.dhx_modal_cover_dv { position: fixed !important; }
</STYLE>
<style>
.toprow table {
border-collapse:collapse;
text-align:left;
width:100%;
}
.matnr {
font:normal 16px/150% Arial, Helvetica, sans-serif;
background:#fff;
overflow:hidden;
border:0px solid #006699;
-webkit-border-radius:3px;
-moz-border-radius:3px;
border-radius:3px;
}
</style>
</head>
<body>
<table border="0" style="display:inline-block; *display: inline;zoom: 1;">
<tbody class="datagrid2">
<tr>
<td class="matnr">Product Code: </td><td class="matnr"> 3061862</td>
</tr>
</tbody>
</table>
<table border="0" style="display:inline-block; *display: inline;zoom: 1;margin-left: 1cm">
<tbody class="datagrid2">
<tr>
<td class="matnr"> Description: </td><td class="matnr">GAVIS,NL,DUO TABS X48 NL</td>
</tr>
</tbody>
</table>
<table border="0">
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
<div id="wrapper">
<div class="toprow">
<table>
<thead>
<tr>
<th colspan="6">Header Data:</th>
</tr>
</thead>
<tbody>
<tr>
<td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Category:</td><td>GI Upper</td><td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Segment:</td><td>Double Action Tablets</td><td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Product Form:</td><td>Tablet Regular</td>
</tr>
<tr>
<td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Cons. Prod. Size:</td><td> 48.000</td><td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Cons.Prod.Size UOM:</td><td>each [EA]</td><td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Brand:</td><td>Gaviscon</td>
</tr>
<tr>
<td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Old Material No:</td><td>3011627</td><td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Global Initiative Number:</td><td>EXGI56</td><td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Global Initiative Name:</td><td>GVS - Existing</td>
</tr>
<tr>
<td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Product Name:</td><td>GVS DOUBLE ACTION 12x4x48</td><td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Material Type:</td><td>Finished Product</td><td width="12%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Primary Pack Type:</td><td>BLI - BLISTER PACK</td>
</tr>
<tr>
<td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Formula:</td><td>0041116</td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Local Project Type:</td><td>NEW TO MARKET</td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Local Project Name:</td><td>DUO TABS</td>
</tr>
<tr>
<td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Promo SKU?:</td><td></td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Promo Type:</td><td></td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Launch Comment:</td><td></td>
</tr>
<tr>
<td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Co-packer Flag:</td><td></td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Co-packer Name:</td><td></td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Reason for sku setup:</td><td>NEW TO MARKET</td>
</tr>
<tr>
<td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">SKU initiator:</td><td>Anton Vandermaesen</td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Change control number:</td><td>000000172735</td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Outer Case Facings:</td><td> 1</td>
</tr>
<tr>
<td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Prime Coding- Expiry:</td><td></td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Prime Coding- Format:</td><td></td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Secon. Coding- Expiry:</td><td></td>
</tr>
<tr>
<td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Project Number:</td><td></td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">New Barcode Req?:</td><td></td><td width="15%" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Factory Catalogue No:</td><td>433</td>
</tr>
<tr>
<td width="15%" class="datagrid4" style="font-weight: bold; border-bottom: 1px solid #0070A8" bgcolor="E1EEF4">EAN Category Desc:</td><td style="border-bottom: 1px solid #0070A8">ITF code - 14 digits</td><td width="15%" class="datagrid4" style="font-weight: bold; border-bottom: 1px solid #0070A8" bgcolor="E1EEF4"></td><td style="border-bottom: 1px solid #0070A8"></td><td width="15%" class="datagrid4" style="font-weight: bold; border-bottom: 1px solid #0070A8" bgcolor="E1EEF4"></td><td style="border-bottom: 1px solid #0070A8"></td>
</tr>
<tr>
<td colspan="1" class="datagrid4" style="font-weight: bold" bgcolor="E1EEF4">Product Comment:</td><td colspan="7"></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
</OptivaSAPFormat>
答案 0 :(得分:1)
XSLT期望格式良好的XML;你的不是。
通过替换
解决问题<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
与
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
或
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"></META>