0

以下では、CSS でタグ名 (スパン) を持つ要素をターゲットにしようとしていますが、以前の Internet Explorer では機能しません...誰かがこの問題の解決策を持っている場合は助けてください...

index.php

<?php header('Content-type: application/xhtml+xml'); ?>

<?xml-stylesheet type="text/xsl" href="copy.xsl"?>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:aa="zz" xmlns:ee="rr">
<head>
    <title></title>
    <style type="text/css">
        /* it work */ aa\:span{background: #00ff00;}
        /* it doesnt work */ span{background: #00ff00;}
    </style>
</head>
<body>
    <aa:span id="span1">
        <aa:p>aaa</aa:p>
    </aa:span>
    <ee:span id="span1">
        <ee:p>aaa</ee:p>
    </ee:span>
</body>
</html>

copy.xsl

<stylesheet version="1.0"
     xmlns="http://www.w3.org/1999/XSL/Transform">
    <template match="/">
        <copy-of select="."/>
    </template>
</stylesheet>
4

1 に答える 1

0

名前空間を使用せずに、すべての要素をプレーンな HTML に変換できます。

<xsl:template match="*">
  <xsl:element name="{local-name()}">
    <xsl:apply-templates select="@* | node()"/>
  </xsl:element>
</xsl:template>

次に、あなたも必要です

<xsl:template match="@* | comment() | text() | processing-instruction()">
  <xsl:copy/>
</xsl:template>

他のノードが変更されずにコピーされるようにします。

だから一緒にあなたは得る

<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="*">
      <xsl:element name="{local-name()}">
        <xsl:apply-templates select="@* | node()"/>
      </xsl:element>
    </xsl:template>

    <xsl:template match="@* | comment() | text() | processing-instruction()">
      <xsl:copy/>
    </xsl:template>

</xsl:stylesheet>
于 2013-06-26T14:42:37.480 に答える