Dom-documenttype-notations

提供:Dev Guides
移動先:案内検索

DOM-DocumentTypeオブジェクト属性-表記法

DTDで宣言された表記法を含む属性_notations_。

_notation.xml_の内容は以下のとおりです-

<?xml version = "1.0"?>
<!DOCTYPE address [
   <!ELEMENT address (#PCDATA)>
   <!NOTATION name PUBLIC "Tanmay">
   <!ATTLIST address category NOTATION (name) #REQUIRED>
]>

<address name = "Tanmay">Hello world!!!!!!</address>

次の例は、_notations_属性の使用方法を示しています-

<!DOCTYPE html>
   <head>
      <script>
         function loadXMLDoc(filename) {
            if (window.XMLHttpRequest) {
               xhttp = new XMLHttpRequest();
            } else//code for IE5 and IE6 {
               xhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xhttp.open("GET",filename,false);
            xhttp.send();
            return xhttp.responseXML;
         }
      </script>
   </head>
   <body>
      <script>
         xmlDoc = loadXMLDoc("/dom/notation.xml");
         var notations = xmlDoc.doctype.notations;
         document.write("notations: "+notations);
         document.write("Item "+notations.getNamedItem('Tanmay'));
      </script>
   </body>
</html>

実行

このファイルを_documenttype_notationsl_としてサーバーパスに保存します(このファイルとnotation.xmlはサーバーの同じパスにある必要があります)。 次のように出力を取得します-

notations: undefined

'_このコレクションはブラウザで非常にまばらにサポートされていますが、このデータを取得する他の方法はありません。_