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 Neil Blue <Ne...@denovopharma.com> on 2004/04/23 10:55:20 UTC
>> Grammar parser getting started help please.
Hello,
I am using xerces 2.6.2, and I am trying to preparse a schema. Here is the test code that I am using:
import org.apache.xerces.xni.parser.*;
import org.apache.xerces.parsers.*;
import org.apache.xerces.xni.grammars.*;
import java.io.*;
public class PSVITest
{
public static void main(String[] args)
throws Exception
{
System.out.println("PSVI Test");
XMLInputSource in = new XMLInputSource(null, null, null);
in.setCharacterStream(new FileReader("test.xsd"));
XMLGrammarPreparser parser = new XMLGrammarPreparser();
Grammar grammar = parser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA
,in);
System.out.println(grammar);
}
}
Schema file:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
This just produces null outputs:
PSVI Test
null
Please can anyone tell me how I can produce a parsed schema grammar?
Thanks
Neil Blue
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: >> Grammar parser getting started help please.
Posted by Michael Glavassevich <mr...@apache.org>.
Hello,
An XMLGrammarLoader for schemas needs to be registered with the
XMLGrammarPreparser. Have a look at the xni.XMLGrammarBuilder sample. You
can register the built-in schema loader like this:
parser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
Hope that helps.
On Fri, 23 Apr 2004, Neil Blue wrote:
> Hello,
>
> I am using xerces 2.6.2, and I am trying to preparse a schema. Here is the test code that I am using:
>
> import org.apache.xerces.xni.parser.*;
> import org.apache.xerces.parsers.*;
> import org.apache.xerces.xni.grammars.*;
> import java.io.*;
>
> public class PSVITest
> {
> public static void main(String[] args)
> throws Exception
> {
> System.out.println("PSVI Test");
> XMLInputSource in = new XMLInputSource(null, null, null);
> in.setCharacterStream(new FileReader("test.xsd"));
> XMLGrammarPreparser parser = new XMLGrammarPreparser();
> Grammar grammar = parser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA
> ,in);
> System.out.println(grammar);
> }
> }
>
> Schema file:
>
> <?xml version="1.0"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.w3schools.com"
> xmlns="http://www.w3schools.com"
> elementFormDefault="qualified">
>
> <xs:element name="note">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="to" type="xs:string"/>
> <xs:element name="from" type="xs:string"/>
> <xs:element name="heading" type="xs:string"/>
> <xs:element name="body" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> </xs:schema>
>
> This just produces null outputs:
>
> PSVI Test
> null
>
> Please can anyone tell me how I can produce a parsed schema grammar?
>
> Thanks
> Neil Blue
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
---------------------------
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@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