DTD Objects and XML Schema Elements

Using the DTD of the document, I did the following:

file.xsl:

<!DOCTYPE xsl:stylesheet[
  <!ENTITY red "rgb(255,0,0)">
]>

<xsl:stylesheet>
   [...]
   <xsl:attribute name="color">&red;</xsl:attribute>
   [...]
</xsl:stylesheet>

I wanted to change everything to an XML schema. So I tried:

file.xsd:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="red" type="xs:token" fixed="rgb(255,0,0)" />
</xsd:schema>

file.xsl:

<xsl:stylesheet
    xmlns:defs="http://www.w3.org/2001/XMLSchema-instance"
    defs:noNamespaceSchemaLocation="file.xsd">

    [...]
    <xsl:attribute name="color"><defs:red/></xsl:attribute>
    [...]
</xsl:stylesheet>

Now parsing a file through Xalan red does not translate, as in the DTD version. Where is my mistake? Are schematic files read during analysis?

+6
source share
2 answers

The attribute fixedin the element definition does not tell the parser to perform textual substitution. It just means that the value of the element must always be the same.

, , XSLT XML, , <defs:red> "rgb(255,0,0)". default fixed, . , , DOM, , "rgb(255,0,0)".

+6

( DTD) .

, , .

DTD . XML .

<?xml version="1.0"?>
<!DOCTYPE foo [
  <!ENTITY red "rgb(255,0,0)">
]>
<foo>
  <bar color="&red;" /> 
</foo>

http://www.ibm.com/developerworks/xml/library/x-tipentref.html

+4

All Articles