Re: Avoid startup overhead by saving compiled large XSD for Xerces-J validation
Mike Beckerle <[email protected]> Fri, 6 May 2022 13:14:37 -0400
| Newsgroups | gmane.text.xml.xerces-j.user |
|---|---|
| Message-ID | <CACQ76njHJBFLiWpgtaAyYJWv9=Ru9uPpCmaO1R836b6uaQi=mw@mail.gmail.com> |
--000000000000f1e44c05de5afe1c Content-Type: text/plain; charset="UTF-8" Created https://issues.apache.org/jira/browse/XERCESJ-1745 On Fri, May 6, 2022 at 1:53 AM Mukul Gandhi <[email protected]> wrote: > Hi Mike, > Answering this question (my personal opinions), while 2.12.3 > release discussion is in progress in another thread :) > > On Thu, May 5, 2022 at 2:09 AM Mike Beckerle <[email protected]> wrote: > > I imagine that to validate XML, Xerces does something akin to > "compiling" the XSD into lower-level data structures for faster use when > actually parsing (and validating) the incoming XML being parsed. > > > > Question 1: Is that true? > > Yes, Xerces compiles/translates XSD syntax to low-level data > structures. I think that, Xerces compiling the XSD syntax into > low-level data structures, is there to adhere to XSD defined component > models of various XSD syntax elements, more than for any performance > reasons. > > > Question 2: Is it possible to get this "compilation" of the large XSD > schema done, and then serialize the resulting java object to a file, and > reload this pre-compiled thing so as not to face this compiling overhead at > startup time? > > I find this is a good idea. > > Although currently not implemented, within Xerces, I think we could > have an api to serialize and deserialize org.apache.xerces.xs.XSModel, > or even javax.xml.validation.Schema to a file (using java's > java.io.Serializable mechanism). I think, currently > org.apache.xerces.xs.XSModel (and many of its dependencies) etc does > not implement the interface java.io.Serializable, which we need to do > so, if we need to implement this feature. > > We also would need to make performance measurements, if in case, we'd > implement XSD schema serialization feature. > > If possibly, you could create a jira issue (new feature) for this > requirement, that can make this requirement easy to track. > > > -- > Regards, > Mukul Gandhi > --000000000000f1e44c05de5afe1c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Created=C2=A0<a href=3D"https://issues.apache.org/jira/bro= wse/XERCESJ-1745">https://issues.apache.org/jira/browse/XERCESJ-1745</a></d= iv><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On = Fri, May 6, 2022 at 1:53 AM Mukul Gandhi <<a href=3D"mailto:mukulg@apach= e.org">[email protected]</a>> wrote:<br></div><blockquote class=3D"gmail= _quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204= ,204);padding-left:1ex">Hi Mike,<br> =C2=A0 =C2=A0 Answering this question (my personal opinions), while 2.12.3<= br> release discussion is in progress in another thread :)<br> <br> On Thu, May 5, 2022 at 2:09 AM Mike Beckerle <<a href=3D"mailto:mbeckerl= [email protected]" target=3D"_blank">[email protected]</a>> wrote:<br> > I imagine that to validate XML, Xerces does something akin to "co= mpiling" the XSD into lower-level data structures for faster use when = actually parsing (and validating) the incoming XML being parsed.<br> ><br> > Question 1: Is that true?<br> <br> Yes, Xerces compiles/translates XSD syntax to low-level data<br> structures. I think that, Xerces compiling the XSD syntax into<br> low-level data structures, is there to adhere to XSD defined component<br> models of various XSD syntax elements, more than for any performance<br> reasons.<br> <br> > Question 2: Is it possible to get this "compilation" of the = large XSD schema done, and then serialize the resulting java object to a fi= le, and reload this pre-compiled thing so as not to face this compiling ove= rhead at startup time?<br> <br> I find this is a good idea.<br> <br> Although currently not implemented, within Xerces, I think we could<br> have an api to serialize and deserialize org.apache.xerces.xs.XSModel,<br> or even javax.xml.validation.Schema to a file (using java's<br> java.io.Serializable mechanism). I think, currently<br> org.apache.xerces.xs.XSModel (and many of its dependencies) etc does<br> not implement the interface java.io.Serializable, which we need to do<br> so, if we need to implement this feature.<br> <br> We also would need to make performance measurements, if in case, we'd<b= r> implement XSD schema serialization feature.<br> <br> If possibly, you could create a jira issue (new feature) for this<br> requirement, that can make this requirement easy to track.<br> <br> <br> -- <br> Regards,<br> Mukul Gandhi<br> </blockquote></div> --000000000000f1e44c05de5afe1c--