You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Ni...@alcatel.co.in on 2003/12/16 11:39:42 UTC
Strange Xerces2 behaviour when validating xmls with namespaceses
hi all
there has been a mail with the same subject some months ago. it was
regarding DOM. I am facing the same problem with XMLReader.
There is a file rtrv_dgn_status.xml and two xsds Dialog.xsd,
DialogTypes.xsd.
Following is the method in which parse is called.
protected void build(InputSource in)
throws JDOMException
{
Document doc = new Document();
try
{
XMLReader parser =
XMLReaderFactory.createXMLReader(saxDriverClass);
if (saxXMLFilter != null)
{
// Connect filter chain to parser
XMLFilter root = saxXMLFilter;
while (root.getParent() instanceof XMLFilter)
{
root = (XMLFilter)root.getParent();
}
root.setParent(parser);
// Read from filter
parser = saxXMLFilter;
}
DefaultHandler contentHandler = new SAXHandler(doc);
parser.setContentHandler(contentHandler);
if (saxEntityResolver != null)
{
parser.setEntityResolver(saxEntityResolver);
}
if (saxDTDHandler != null)
{
parser.setDTDHandler(saxDTDHandler);
}
parser.setProperty(
"http://xml.org/sax/properties/lexical-handler",
contentHandler);
lexicalReporting = true;
// Set validation
try
{
parser.setFeature("http://xml.org/sax/features/validation",
validate);
parser.setFeature(
"http://apache.org/xml/features/validation/schema",
validate);
parser.setFeature("http://xml.org/sax/features/namespaces",
true);
parser.setFeature(
"http://xml.org/sax/features/namespace-prefixes",
false);
if (saxErrorHandler != null)
{
parser.setErrorHandler(saxErrorHandler);
}
else
{
parser.setErrorHandler(contentHandler);
}
}
catch (SAXNotSupportedException e)
{
}
catch (SAXNotRecognizedException e)
{
}
parser.parse(in);
System.out.println("parsed successfully");
}
catch (Exception e)
{
}
Attached are the corresponding xml and xsd files
Thanks and Regards
Nitin Gupta
(See attached file: DialogTypes.xsd)(See attached file: Dialog.xsd)(See
attached file: rtrv_dgn_status.xml)
Re: Finding out the Data Type defined in the XML schema at run time
which I need for conditional formatting in my call back methods
Posted by Venu <K....@Sun.COM>.
look into the psvi sample provided in xerces and see if it helps
you.
Shailesh Vaidya wrote:
> Hi all,
>
> Is there any way to find out the data type defined in XML schema in my
> call back methods, we are using the validating parser with validation
> feature set to true.
>
> Thanks and Regards
>
> Shailesh
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
--
Regards,
Venu
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Finding out the Data Type defined in the XML schema at run time which I need for conditional formatting in my call back methods
Posted by Shailesh Vaidya <sh...@Yojna.com>.
Hi all,
Is there any way to find out the data type defined in XML schema in my
call back methods, we are using the validating parser with validation
feature set to true.
Thanks and Regards
Shailesh
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: Strange Xerces2 behaviour when validating xmls with namespaceses
Posted by Venu <K....@Sun.COM>.
Hi Nitin ,
A quick answer is to set the following feature to true.
http://apache.org/xml/features/validation/dynamic
let us know.
-venu
Nitin.Gupta@alcatel.co.in wrote:
> hi all
> there has been a mail with the same subject some months ago. it was
> regarding DOM. I am facing the same problem with XMLReader.
> There is a file rtrv_dgn_status.xml and two xsds Dialog.xsd,
> DialogTypes.xsd.
> Following is the method in which parse is called.
>
>
> protected void build(InputSource in)
> throws JDOMException
> {
>
> Document doc = new Document();
> try
> {
> XMLReader parser =
> XMLReaderFactory.createXMLReader(saxDriverClass);
>
> if (saxXMLFilter != null)
> {
>
> // Connect filter chain to parser
> XMLFilter root = saxXMLFilter;
>
> while (root.getParent() instanceof XMLFilter)
> {
> root = (XMLFilter)root.getParent();
> }
>
> root.setParent(parser);
>
> // Read from filter
> parser = saxXMLFilter;
> }
>
> DefaultHandler contentHandler = new SAXHandler(doc);
> parser.setContentHandler(contentHandler);
>
> if (saxEntityResolver != null)
> {
> parser.setEntityResolver(saxEntityResolver);
> }
>
> if (saxDTDHandler != null)
> {
> parser.setDTDHandler(saxDTDHandler);
> }
>
> parser.setProperty(
>
> "http://xml.org/sax/properties/lexical-handler",
> contentHandler);
> lexicalReporting = true;
>
> // Set validation
> try
> {
>
> parser.setFeature("http://xml.org/sax/features/validation",
> validate);
> parser.setFeature(
>
> "http://apache.org/xml/features/validation/schema",
> validate);
>
> parser.setFeature("http://xml.org/sax/features/namespaces",
> true);
> parser.setFeature(
>
> "http://xml.org/sax/features/namespace-prefixes",
> false);
>
> if (saxErrorHandler != null)
> {
> parser.setErrorHandler(saxErrorHandler);
> }
> else
> {
> parser.setErrorHandler(contentHandler);
> }
> }
> catch (SAXNotSupportedException e)
> {
> }
> catch (SAXNotRecognizedException e)
> {
> }
> parser.parse(in);
> System.out.println("parsed successfully");
> }
> catch (Exception e)
> {
> }
>
>
> Attached are the corresponding xml and xsd files
>
>
> Thanks and Regards
>
> Nitin Gupta
>
>
> (See attached file: DialogTypes.xsd)(See attached file: Dialog.xsd)(See
> attached file: rtrv_dgn_status.xml)
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org