schema2src & XML mode

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

schema2src & XML mode

Mathias Weyel
Hi all,

I have had a try with schema2src and it didn't seem to run at all. I
created a simple xsd schema and tried to run the tool and it raised NPEs.

I tried: java -cp scala-library.jar;schema2src.jar schema2src.Main xsd  
-d c:\temp article.xsd c:\Temp
and got:
Exception in thread "main" java.lang.ExceptionInInitializerError
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Unknown Source)
       at schema2src.Main$.main(Main.scala:29)
       at schema2src.Main.main(Main.scala)
Caused by: java.lang.NullPointerException
       at schema2src.Module$ModuleConfig.<init>(Module.scala:14)
       at schema2src.xsd.Driver$XsdConfig.<init>(Driver.scala:14)
       at schema2src.xsd.Driver$.<init>(Driver.scala:12)
       at schema2src.xsd.Driver$.<clinit>(Driver.scala)
       ... 4 more

I am not sending the xsd along because it seems the error does happen
before parsing of the schema begins. It is available on request though.

I am sure, I am doing something wrong but I fail to figure out what that
is. I used the latest version from sbaz.

The second thing is the XML Mode. I want to write XHTML and now have the
problem on how to put Scala-Expressions into attribute values. Writing
something like

<p>{article.text}</p> works like it should but when we have double
quotes, the mode is not changed: <p id="{article.header}">...</p> yields
the string "{article.header}" as attribute value. How can I insert
calculated values into the XML between quotes?

Thx

Mathias


Reply | Threaded
Open this post in threaded view
|

Re: schema2src & XML mode

Burak Emir
Hi Mathias,

Mathias Weyel wrote:

> Hi all,
>
> I have had a try with schema2src and it didn't seem to run at all. I
> created a simple xsd schema and tried to run the tool and it raised NPEs.
>
first and foremost: don't panic!  :-)

The NPE was easy to fix, but the xsd module doesn't *do* anything yet --
sorry if you had expected something more. When I wrote the string
"experimental xsd binding" I had forgotten myself that the thing is
actually not functional. But it might be in a short while, I am back to
it now.

>
> I am not sending the xsd along because it seems the error does happen
> before parsing of the schema begins. It is available on request though.
>
If you would, it will likely raise the chances of your used
schema-features being supported (as a little recompensation for trying
out bleeding edge software:-)

Seriously, I am not keen on supporting *all* esoteric XSD, and some
real-life examples would be good test cases. Sadly, I don't know what of
the 1000s of available schemas should be considered real-life.
 

> I am sure, I am doing something wrong but I fail to figure out what
> that is. I used the latest version from sbaz.

again, sorry.

>
> The second thing is the XML Mode. I want to write XHTML and now have
> the problem on how to put Scala-Expressions into attribute values.
> Writing something like
>
> <p>{article.text}</p> works like it should but when we have double
> quotes, the mode is not changed: <p id="{article.header}">...</p>
> yields the string "{article.header}" as attribute value. How can I
> insert calculated values into the XML between quotes?
>
Don't think in quotes, think elements and attributes.
Our syntax is slightly different from XQuery's, in that we require <p
id={article.header}>. Remember that this is desugarized to something like

scala.xml.Elem(...,"p", ...UnprefixedAttribute("id", article.header,
...), ...)

There are no quotes, but they will be written when you serialize the
whole thing (toString()), not before. The serialization is intelligent
enough to use " or ' depending on what is in your string.

cheers,
Burak

--
Burak Emir

http://lamp.epfl.ch/~emir