XSLTを使用してHTMLファイルの属性を取り除くことを検討しています。 HTMLファイルには、次のようになります。それがコンセプトの証明であると私はそれぞれのdivのための新しいタグでに探していますXSLT書式設定HTML入力
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title>CB Comfy Bike</title>
<meta name="atg:string,index:$repositoryId" content="prod10005" />
<meta name="atg:date:creationDate" content="955050507" />
<meta name="atg:date:startDate" content="978325200" />
<meta name="atg:date:endDate" content="1009861200" />
<meta name="atg:string:$url"
content="atgrep:/ProductCatalog/frame-product/prod10005?locale=en_US" />
<meta name="atg:string,index:$baseUrl"
content="atgrep:/ProductCatalog/frame-product/prod10005" />
<meta name="atg:string:$repository.repositoryName" content="ProductCatalog" />
<meta name="atg:string:$itemDescriptor.itemDescriptorName" content="frame-product" />
<meta name="atg:string:childSKUs.$repositoryId" content="sku20007" />
<meta name="atg:string:childSKUs.$itemDescriptor.itemDescriptorName" content="bike-sku" />
<meta name="atg:date:childSKUs.creationDate" content="955068027" />
<meta name="atg:float:childSKUs.listPrice" content="400.0" />
<meta name="atg:float:childSKUs.salePrice" content="300.0" />
<meta name="atg:boolean:childSKUs.onSale" content="false" />
<meta name="atg:string:parentCategory.$repositoryId" content="cat55551" />
<meta name="atg:date:parentCategory.creationDate" content="956950321" />
<meta name="atg:string,docset:ancestorCategories.$repositoryId" content="cat10002" />
<meta name="atg:string,docset:ancestorCategories.$repositoryId" content="cat10003" />
<meta name="atg:string,docset:ancestorCategories.$repositoryId" content="cat55551" />
</head>
<body>
<div class="atg:role:displayName" id="0"> CB Comfy Bike </div>
<div class="atg:role:longDescription" id="1"> This bike is just right, whether you are a
commuter or want to explore the fire roads. The plush front suspension will smooth out
the roughest bumps and the big disc brakes provide extra stopping power for those big
downhills. </div>
<div class="atg:role:keywords" id="2"> mountain_bike comfort_bike </div>
<div class="atg:role:childSKUs.displayName" id="3"> CB Comfy Bike Medium </div>
<div class="atg:role:childSKUs.listPrice" id="4"> 400.0 </div>
<div class="atg:role:childSKUs.description" id="5"> Medium </div>
<div class="atg:role:parentCategory.displayName" id="6"> Mountain Bikes </div>
</body>
</html>
、私は、まだconvensions命名に焦点を当てていません。しかし、どのようにdivタグを区別するのか分からない。私がこれまで持っているこのXSLTは、次のとおりです。
返し<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="head"/>
<xsl:template match="body">
<xsl:copy>
<xsl:value-of select="div/text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
:
<?xml version="1.0" encoding="utf-8"?>
<html>
<body> CB Comfy Bike </body>
</html>
私はこの
<?xml version="1.0" encoding="UTF-8"?>
<root>
<tag1>CB Comfy Bike</tag1>
<tag2>This bike is just right, whether you are a
commuter or want to explore the fire roads. The plush front suspension will smooth out
the roughest bumps and the big disc brakes provide extra stopping power for those big
downhills.</tag2>
<tag3>mountain_bike comfort_bike</tag3>
<tag4>CB Comfy Bike Medium</tag4>
<tag5>400.0</tag5>
<tag6>Medium</tag6>
<tag7>Mountain Bikes</tag7>
</root>
のようなものの中に私が間に差別されているトラブルの入力を有効にする方法を
をDivタグ。
一部の(すべて?)XSLTプロセッサで任意のHTMLを処理する際に問題が発生することがあります。心に浮かぶ主なものは、XML仕様で多くの名前付きエンティティがないことです。 私が間違っていると誰かが私を修正できますか? – Sprague