freaking1 / jing-trang

Automatically exported from code.google.com/p/jing-trang
Other
1 stars 0 forks source link

Null pointer exception converting RNG to XSD #108

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. java -jar trang.jar books.rng books.xsd
2.
3.

What is the expected output? What do you see instead?
Expected
books.xsd which is an XSD version of the books.rng file (attached)
Got
Null pointer exception:
----------
Exception in thread "main" java.lang.NullPointerException
    at 
com.thaiopensource.relaxng.output.xsd.basic.SchemaTransformer.visitComplexC
ontent(SchemaTransformer.java:94)
    at 
com.thaiopensource.relaxng.output.xsd.basic.SchemaTransformer.visitComplexC
ontent(SchemaTransformer.java:6)
    at 
com.thaiopensource.relaxng.output.xsd.basic.ComplexTypeComplexContent.accep
t(ComplexTypeComplexContent.java:24)
    at 
com.thaiopensource.relaxng.output.xsd.basic.SchemaTransformer.visitElement(
SchemaTransformer.java:57)
    at 
com.thaiopensource.relaxng.output.xsd.Transformer.visitElement(Transformer.
java:467)
    at 
com.thaiopensource.relaxng.output.xsd.Transformer.visitElement(Transformer.
java:44)
    at 
com.thaiopensource.relaxng.output.xsd.basic.Element.accept(Element.java:25)
    at 
com.thaiopensource.relaxng.output.xsd.basic.SchemaTransformer.visitGroup(Sc
hemaTransformer.java:23)
    at 
com.thaiopensource.relaxng.output.xsd.basic.GroupDefinition.accept(GroupDef
inition.java:22)
    at 
com.thaiopensource.relaxng.output.xsd.basic.Schema.accept(Schema.java:103)
    at 
com.thaiopensource.relaxng.output.xsd.basic.SchemaTransformer.transform(Sch
emaTransformer.java:19)
    at 
com.thaiopensource.relaxng.output.xsd.XsdOutputFormat.output(XsdOutputForma
t.java:58)
    at com.thaiopensource.relaxng.translate.Driver.run(Driver.java:144)
    at com.thaiopensource.relaxng.translate.Driver.main(Driver.java:44)

What version of the product are you using? On what operating system?
20091111
Windows 7 64 Bit

Please provide any additional information below.

Tried in Oxygen (same error)
Tried manually with my own code in Java calling Driver (same error)

Original issue reported on code.google.com by dlee.cal...@gmail.com on 3 May 2010 at 8:11

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks David,

Here it is a smaller sample file that can be used to reproduce the issue:

<grammar xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
    <element name="test">
      <mixed>
        <attribute name="a"/>
      </mixed>
    </element>
  </start>
</grammar>

As a workaround you can move the attribute outside the mixed pattern. In your 
case
that means writing the CATEGORIES pattern as below:

    <define name="CATEGORIES">
        <choice>
            <notAllowed/>
            <element name="CATEGORIES">
                <attribute name="DESC">
                    <data type="string"/>
                </attribute>
                <mixed>
                    <zeroOrMore>
                        <ref name="CATEGORY"/>
                    </zeroOrMore>
                </mixed>
            </element>
        </choice>
    </define>

An alternative workarouns is to replace the mixed with interleave and add a text
pattern inside interleave, as described here
http://relaxng.org/spec-20011203.html#IDA0FZR
resulting:

    <define name="CATEGORIES">
        <choice>
            <notAllowed/>
            <element name="CATEGORIES">
                <interleave>
                    <attribute name="DESC">
                        <data type="string"/>
                    </attribute>
                    <zeroOrMore>
                        <ref name="CATEGORY"/>
                    </zeroOrMore>
                    <text/>
                </interleave>
            </element>
        </choice>
    </define>

Best Regards,
George

Original comment by georgebina76 on 4 May 2010 at 12:30

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2342.

Original comment by georgebina76 on 25 May 2010 at 12:18

GoogleCodeExporter commented 9 years ago

Original comment by georgebina76 on 25 May 2010 at 12:22