使用XSL在Siebel中使用XSLT1.0转换HTML?

时间:2017-03-10 02:35:58

标签: html xslt-1.0

我有一个像这样的HTML。我需要使用XSLT 1.0并根据其中一个元素中子元素的属性值删除以下HTML中某个元素下面的元素。

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	</head>
	<body lang="EN-US">
		<div class="WordSection1">
			<p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">This is the document for ER Overview<o:p/>
				</span>
			</p>
			<p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Test 1  <o:p/>
				</span>
			</p>  <p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">2<o:p/>
				</span>
			</p>  <p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;background:yellow;mso-highlight:yellow">3</span>
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">
					<o:p/>
				</span>
			</p>  <p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">4<o:p/>
				</span>
			</p>  <p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;background:lime;mso-highlight:lime">5</span>
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">
					<o:p/>
				</span>
			</p>  
			<p class="MsoNormal">
				<a name="_MailEndCompose">
					<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">
						<o:p>&nbsp;</o:p>
					</span>
				</a>
			</p>
			<span style="mso-bookmark:_MailEndCompose"/>
			<div>
				<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
					<p class="MsoNormal">
						<a name="_____replyseparator"/>
						<b>
							<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">From:</span>
						</b>
						<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"> AutoReply [mailto:reply@support.com]<br>
								<b>Sent:</b> Thursday, March 2, 2017 6:50 PM<br>
									<b>To:</b> Doe, John &lt;johndoe@support.com&gt;<br>
										<b>Subject:</b> This is a test for routing rules<o:p/>
									</span>
								</p>
							</div>
			</div>
							<p class="MsoNormal">
								<o:p>&nbsp;</o:p>
							</p>
							<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="500" style="width:375.0pt">
								<tbody>
									<tr>
										<td style="padding:0in 0in 0in 0in">
											<p class="MsoNormal">The contents of the note are included below.<br>
													<br>If reply includes an attachment/image, please go Transaction Center to view the file.<br>
															<br>To add a Note, simply reply to the email.<br>Please do not edit the email subject.<br>
																		<br>The following note was posted by <a href="mailto:johndoe@support.com">johndoe@support.com</a>:<o:p/>
																		</p>
										</td>
									</tr>
									<tr>
										<td style="padding:0in 0in 0in 0in">
											<p class="MsoNormal">_______________________________________________________________________<br>
													<br>
														<o:p/>
													</p><p class="MsoNormal">
														<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Test 1</span>
														<o:p/>
													</p><p class="MsoNormal">
														<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">2</span>
														<o:p/>
													</p><p class="MsoNormal">
														<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;background:yellow;mso-highlight:yellow">3</span>
														<o:p/>
													</p><p class="MsoNormal">
														<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">4</span>
														<o:p/>
													</p><p class="MsoNormal">
														<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;background:lime;mso-highlight:lime">5</span>
														<o:p/>
													</p><p class="MsoNormal">
														<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">&nbsp;</span>
														<o:p/>
													</p>
													<div>
														<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
															<p class="MsoNormal">&lt;a name=&quot;<o:p/>
															</p>
														</div><p class="MsoNormal">
															<br>_______________________________________________________________________<o:p/>
															</p>
														</div>
													</td>
									</tr>
									<tr>
										<td style="padding:0in 0in 0in 0in">
											<p class="MsoNormal">Technical Support.<br>
													<br>
														<br>****************** Internal Use Only ******************<br>To view this request in the CIS View, use the following URL:<br>
											</p>
										</td>
									</tr>
								</tbody>
							</table>
							<p class="MsoNormal">
								<o:p>&nbsp;</o:p>
							</p>
							<div class="MsoNormal" align="center" style="text-align:center">
								<hr size="3" width="100%" align="center">
							</div>
							<p class="MsoNormal">
								<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,sans-serif;color:black">
									<br>Confidentiality Notice.<br>
							</p>
		</div>
	</body>
</html>

我需要删除<p>标记下面包含<a name="_MailEndCompose">子标记的所有元素。输出应该类似于下面的HTML。

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	</head>
	<body lang="EN-US">
		<div class="WordSection1">
			<p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">This is the document for ER Overview<o:p/>
				</span>
			</p>
			<p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Test 1  <o:p/>
				</span>
			</p>  <p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">2<o:p/>
				</span>
			</p>  <p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;background:yellow;mso-highlight:yellow">3</span>
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">
					<o:p/>
				</span>
			</p>  <p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">4<o:p/>
				</span>
			</p>  <p class="MsoNormal">
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;background:lime;mso-highlight:lime">5</span>
				<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">
					<o:p/>
				</span>
			</p>  
			<p class="MsoNormal">
				<a name="_MailEndCompose">
					<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">
						<o:p>&nbsp;</o:p>
					</span>
				</a>
			</p>
     </div>
	</body>
</html>

真的很感谢你的帮助大师。谢谢大家。

1 个答案:

答案 0 :(得分:0)

我不是Siebel编程,但这两个模板可能会对您有所帮助。它们适用于Microsoft的1.0 XSLT。也许你可以利用。

<!-- Identity template -->
<xsl:template match="@* | node()">
    <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
</xsl:template>

<!-- Suppress everything after the mail end compose. -->
<xsl:template match="*[preceding::p[.//a[@name='_MailEndCompose']]]"/>
相关问题