[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fixed attributes in Schemas
- From: LKirschner@vencast.com
- To: xml-dev@lists.xml.org
- Date: Wed, 28 Feb 2001 15:24:40 -0500
I'm working on a schema that employs fixed attributes, but when I parse
instance documents the attributes are not defined.
I define the fixed attribute 'pattern' as follows:
<element name="java.sql.Date" >
<complexType>
<simpleContent>
<extension base="date" >
<attribute name="pattern" type="string" use="fixed"
value="yyyy-MM-dd" />
</extension>
</simpleContent>
</complexType>
</element>
...and test with the following document:
<?xml version="1.0"?>
<db_bean xmlns="http://schemahost/xml/namespaces/db_bean"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation="http://schemahost/xml/namespaces/db_bean
db_bean.xsd"
class="com.vencast.bean.db.DealComponent">
<property name="lastUpdateDate" >
<java.sql.Date>2000-01-02</java.sql.Date>
</property>
</db_bean>
...but when I parse the document, but when I try to retrieve the attribute
it is not defined:
public void startElement ( String namespaceURI , String localName , String
qName , Attributes atts ) throws SAXException
{
if ( qName . equals ( "java.sql.Date" ) )
{
pattern = atts . getValue ( "pattern" ) ;
}
}
I am parsing with SAXParser from apache xerces-1-2-3, which is supposed to
support fixed anbd default attributes.
I'm putting the full schema below in case some other section might be
causing the problem.
Thanks in advance for any help,
--Larry
<schema xmlns="http://www.w3.org/2000/10/XMLSchema"
targetNamespace="http://schemahost/xml/namespaces/db_bean"
elementFormDefault="qualified"
xmlns:dbb="http://schemahost/xml/namespaces/db_bean">
<element name="db_bean">
<complexType>
<annotation>
<documentation></documentation>
</annotation>
<sequence>
<element name="property" minOccurs="0" maxOccurs
="unbounded" >
<complexType>
<choice>
<element name="java.lang.Boolean" type
="boolean" />
<element name="java.lang.Byte" type
="byte" />
<element name="java.sql.Date" >
<complexType>
<simpleContent>
<extension base="date" >
<attribute name
="pattern" type="string" use="fixed" value="yyyy-MM-dd" />
</extension>
</simpleContent>
</complexType>
</element>
<element name="java.lang.Double" type
="double" />
<element name="java.lang.Float" type
="float" />
<element name="java.lang.Integer" type
="integer" />
<element name="java.lang.Long" type
="long" />
<element name="java.lang.Short" type
="short" />
<element name="java.lang.String" type
="string" />
<element name="java.sql.Time" >
<complexType>
<simpleContent>
<extension base="time" >
<attribute name
="pattern" type="string" use="fixed" value="yyyy-MM-ddHH:mm:ss.SS0" />
<attribute name
="zero_epoch" type="string" use="fixed" value="1970-01-01" />
</extension>
</simpleContent>
</complexType>
</element>
<element name="java.sql.Timestamp" >
<complexType>
<simpleContent>
<extension base
="timeInstant" >
<attribute name
="pattern" type="string" use="fixed" value="yyyy-MM-ddTHH:mm:ss-SS-00" />
</extension>
</simpleContent>
</complexType>
</element>
</choice>
<attribute name="name" use="required" >
<simpleType>
<restriction base="string" >
<pattern value="[a-z|A-Z|_]
[\w|_]*" >
<annotation>
<documentation>java_names must follow Java class naming rules: the first
character must be a letter or '_'; the characters that follow may be
letters, '_', or numbers</documentation>
</annotation>
</pattern>
</restriction>
</simpleType>
</attribute>
</complexType>
</element>
</sequence>
<attribute name="class" use="required" >
<simpleType>
<restriction base="string" >
<pattern value="[a-z|A-Z|_][\w|_|.]*" >
<annotation>
<documentation>java_names must
follow Java class naming rules: the first character must be a letter or '
_'; the characters that follow may be letters, '_', or numbers. Periods can
be used for package delimitation: ie com.vencast.SomeClass</documentation>
</annotation>
</pattern>
</restriction>
</simpleType>
</attribute>
</complexType>
</element>
</schema>