// Out current parser (Piccolo) does not error when a
// namespace is used and not defined. Check for these here
if (qName.indexOf( ':' ) >= 0 && namespaceURI.length() == 0)
{
XmlError err =
XmlError.forMessage(
"Use of undefined namespace prefix: " +
qName.substring( 0, qName.indexOf( ':' ) ));
throw new XmlRuntimeException( err.toString(), null, err );
}
_context.begin( localName, namespaceURI );
// BUGBUG - do more of the following to get line number for
// as many parts of the XML as we can
if (_wantLineNumbers)
{
_context.lineNumberAnnotation(
_startLocator.getLineNumber(),
_startLocator.getColumnNumber(),
-1 );
}
for ( int i = 0, len = atts.getLength() ; i < len ; i++ )
{
String aqn = atts.getQName( i );
if (aqn.equals( "xmlns" ))
{
_context.xmlns( "", atts.getValue( i ) );
}
else if (aqn.startsWith( "xmlns:" ))
{
String prefix = aqn.substring( 6 );
if (prefix.length() == 0)
{
XmlError err =
XmlError.forMessage( "Prefix not specified", XmlError.SEVERITY_ERROR );
throw new XmlRuntimeException( err.toString(), null, err );
}
String uri = atts.getValue( i );
if (uri.length() == 0)
{
XmlError err =
XmlError.forMessage(
"Prefix can't be mapped to no namespace: " + prefix,
XmlError.SEVERITY_ERROR );
throw new XmlRuntimeException( err.toString(), null, err );
}
_context.xmlns( prefix, uri );
}
else