<div dir="auto">All, I'd like to add regexes to the JSON schema from X3DUOM, but my time is getting stretched.      The schema generator code is here:<div dir="auto"><br></div><div dir="auto"><a href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/python/etgenerateJSONschema.py">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/python/etgenerateJSONschema.py</a><br></div><div dir="auto"><br></div><div dir="auto">Perhaps someone familiar with JSON and python can take the task.  Cecile?</div><div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto"><br></div><div dir="auto">John</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jun 8, 2018, 2:29 AM Don Brutzman <<a href="mailto:brutzman@nps.edu" target="_blank" rel="noreferrer">brutzman@nps.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Lots of great questions.  Apologies for not answering as best possible, am traveling.<br>
<br>
a. Haven't included leading or trailing whitespace since examples all get canonicalized first.<br>
<br>
Also the X3D XML Schema constructs all include <xs:whiteSpace value="collapse"/> for validation<br>
<br>
b. We should also try to come up with a subpattern that handles one-and-only-one comma amidst other optional whitespace, avoiding catastrophic backtracking.  The X3D and VRML encodings say to treat them as whitespace.  The XML schema honors that but carefully - not allowing excess commas to go unnoticed since historically is the only indicator that a long line of values has gotten corrupted.<br>
<br>
c. the differences of regex syntax among various languages are relatively minor and explained at length in lots of documentation... we should be able to avoid idiosyncrasies without too much trouble (i think that is the case already).<br>
<br>
d. looked online and found plausible exemplars om stackoverflow; have added regex patterns for SF/MFBool, SFInt32, SFFloat/Double/Time.  comments in x3d v4 schema show links.<br>
<br>
e. have copied over from XML Schema and added regex patterns to X3DUOM for each field type.  example:<br>
<br>
<FieldType type="SFImage"<br>
        regex="[ \t]*(([0-9]|[1-9][0-9]+)([ ]+|$)){3}(([0-9]|([1-9][0-9]+)|(0x([0-9]|[a-f]|[A-F])+))([ ]+|$))*"><br>
    <InterfaceDefinition specificationUrl="<a href="http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage</a>"<br>
        appinfo="The SFImage field specifies a single uncompressed 2-dimensional pixel image. SFImage fields contain three integers representing the width, height and number of components in the image, followed by (width x height) hexadecimal or integer values representing the pixels in the image."/><br>
</FieldType><br>
<br>
f. X3DJSAIL support: have used this X3DUOM information further and added regex values and regex testing to field type objects.  this should facilitate experimentation and everyday usage even further.<br>
<br>
<a href="http://www.web3d.org/specifications/java/X3DJSAIL.html#regex" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/java/X3DJSAIL.html#regex</a><br>
<br>
"Regular expression (regex) support in field types, for example SFVec3fObject REGEX string, pattern, matches() and matches(String value)."<br>
<br>
<a href="http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/SFVec3fObject.html#REGEX" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/SFVec3fObject.html#REGEX</a><br>
<a href="http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/SFVec3fObject.html#pattern" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/SFVec3fObject.html#pattern</a><br>
<a href="http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/SFVec3fObject.html#matches--" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/SFVec3fObject.html#matches--</a><br>
<a href="http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/SFVec3fObject.html#matches-java.lang.String-" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/SFVec3fObject.html#matches-java.lang.String-</a><br>
<br>
Tested in HelloWorldProgram.java satisfactorily:<br>
<br>
<!-- SFVec3f default=0 0 0, initial=1 2 3, setValue=4 5 6, multiply(2)=8 10 12, normalize()=0.45584232 0.5698029 0.68376344, regex matches()=true --><br>
<!-- regex SFVec3f().matches("1 2 3")=true, regex SFVec3f().matches("1 2 3 4")=false --><br>
<br>
Having fun with X3D Regexes!<br>
<br>
<a href="http://www.web3d.org/specifications/X3dRegularExpressions.html" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/X3dRegularExpressions.html</a><br>
<br>
On 6/7/2018 2:27 PM, Andreas Plesch wrote:<br>
> Apologies for using this thread to keep a record since this is getting technical.<br>
> <br>
> The XML encoding for SFImage<br>
> <br>
> <a href="http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFImage" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFImage</a><br>
> <br>
> mentions whitespace as separator for pixel values. So that would include any kind of whitespace, and perhaps repeated whitespace.<br>
> <br>
> Looking at XML, it has its own regex definition including character classes:<br>
> <br>
> <a href="https://www.w3.org/TR/xmlschema11-2/#cces" rel="noreferrer noreferrer noreferrer" target="_blank">https://www.w3.org/TR/xmlschema11-2/#cces</a><br>
> <br>
> 4.2.5 lists popular classes including \d for decimal digits and \s for common whitespace. So it should be possible to use those as they are wildly recognized outside of XML as well.<br>
> <br>
> XML regexes also are anchored implicitly at the start and end, meaning there are no partial matches. Since this is unusual outside of XML, it probably should be mentioned somewhere on the x3d regex page. This is especially important if the regexes are intended to be used for other encodings such as VRML as well.<br>
> <br>
> -Andreas<br>
> <br>
> On Thu, Jun 7, 2018 at 4:55 PM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com" rel="noreferrer noreferrer" target="_blank">andreasplesch@gmail.com</a> <mailto:<a href="mailto:andreasplesch@gmail.com" rel="noreferrer noreferrer" target="_blank">andreasplesch@gmail.com</a>>> wrote:<br>
> <br>
>     Two more observations which may be worth while being stated explicitly:<br>
> <br>
>     The regexes are expected to be used just against attribute strings, not the complete element xml, or scene xml . I think that is implied by how XML native data types are referenced.<br>
>     Partial matches do not count as successful. That means, there needs to be an additional check if the matched portion of the string is identical to the string. I think that is implied how the existing regexes are formulated.<br>
> <br>
>     And two more question:<br>
> <br>
>     The existing regexes do not allow for leading white space. It looks like this is inspired by XML spec. regexes: <a href="https://www.w3.org/TR/xmlschema11-2/#decimal" rel="noreferrer noreferrer noreferrer" target="_blank">https://www.w3.org/TR/xmlschema11-2/#decimal</a> . However, native XML decimal integers and floats allow leading white space due to the fixed  whiteSpace: collapse restriction.<br>
>     Should therefore optional leading white space be added to the existing regexes ? I think so, or alternatively removed from native using types (by not using native types).<br>
>     For SF fields which contain multiple numbers, such as SFVec or SFColor, the existing regexes require exactly one space character as separator. What is the rationale for not allowing repeated space characters which may help with formatting ?<br>
> <br>
>     -Andreas<br>
> <br>
>     On Thu, Jun 7, 2018 at 2:11 PM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com" rel="noreferrer noreferrer" target="_blank">andreasplesch@gmail.com</a> <mailto:<a href="mailto:andreasplesch@gmail.com" rel="noreferrer noreferrer" target="_blank">andreasplesch@gmail.com</a>>> wrote:<br>
> <br>
>         Since I got started with the regexes, let's look at SFImage as it is still a TODO.<br>
> <br>
>         <a href="http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage</a><br>
> <br>
>         appears to be the main (only?) source of the format description.<br>
> <br>
>         We need exactly three decimal non-negative integers followed by a zero or more non-negative decimal or hexadecimal integers.<br>
> <br>
>         There is no mentioning of the separator, so let's look at some example scenes:<br>
> <br>
>         <a href="http://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/PixelTexture/index.html" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/PixelTexture/index.html</a><br>
> <br>
>         The NIST examples all use space as separator.<br>
>         <a href="http://www.web3d.org/x3d/tooltips/X3dTooltips.html#PixelTexture" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/x3d/tooltips/X3dTooltips.html#PixelTexture</a> examples all use space.<br>
> <br>
>         <a href="http://www.web3d.org/specifications/X3dSchemaDocumentation4.0/x3d-4.0_SFImage.html" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/X3dSchemaDocumentation4.0/x3d-4.0_SFImage.html</a> has a minimum length of 5, presumably as a result of three single digits for wdth, height and components plus two separator characters.<br>
> <br>
>         So one question is: Are single commas legal to separate numbers in SFImage from each other ? <a href="http://www.web3d.org/specifications/X3dRegularExpressions.html" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/X3dRegularExpressions.html</a> says commas are only allowed in MF fields, so let's say the answer is no.<br>
> <br>
>         What about leading zeroes ? The general guidance in <a href="http://www.web3d.org/specifications/X3dRegularExpressions.html" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/specifications/X3dRegularExpressions.html</a> does not allow leading zeroes.<br>
> <br>
>         There is a requirement to have width x height x component number of pixel values but I am not sure if this requirement can be (easily) checked by a regex.<br>
> <br>
>         Capital letters: <a href="http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage" rel="noreferrer noreferrer noreferrer" target="_blank">http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage</a> only uses capital A-F in hexadecimal example values but let's say a-f is also allowed since they are used in almost all examples.<br>
> <br>
>         Ok, let's give it a try:<br>
> <br>
>         [ \t]*(([0-9]|[1-9][0-9]+)([ ]+|$)){3}(([0-9]|([1-9][0-9]+)|(0x([0-9]|[a-f]|[A-F])+))([ ]+|$))*<br>
> <br>
>         In words:<br>
> <br>
>         match any leading white space followed by<br>
>         exactly three times the following<br>
>           - one of the following<br>
>             - either a single digit (including 0) or<br>
>             - a two or more digit number starting with a 1 to 9 digit<br>
>           - followed by either<br>
>            - one or more spaces<br>
>            - or the end of the string (accommodating the default '0 0 0' case)<br>
>         then optionally followed zero or more times by<br>
>            - one of the following<br>
>              - either a single digit (including 0) or<br>
>              - a two or more digit number starting with a 1 to 9 digit<br>
>              - 0x followed by at least one of<br>
>                 - a single digit or<br>
>                 - a to f letter or<br>
>                 - A to F letter<br>
>            - followed by either<br>
>              - one or more spaces<br>
>              - or the end of the string<br>
>         The spaces are written as [ ] for clarity but could be just a space character.<br>
> <br>
>         This allows 0 0 0 as it is the default value. It also allows 1 2 3 without any pixel values.but we do not aim at checking the number of pixel values anyways.<br>
> <br>
>         Any input, in particular examples of problem cases welcome. Since images can be huge it may be necessary to optimize for performance and memory which may require more regex expertise than I can bring myself to acquire.<br>
> <br>
>         -Andreas<br>
> <br>
>         -- <br>
>         Andreas Plesch<br>
>         Waltham, MA 02453<br>
> <br>
> <br>
> <br>
>     -- <br>
>     Andreas Plesch<br>
>     Waltham, MA 02453<br>
> <br>
> <br>
> <br>
> -- <br>
> Andreas Plesch<br>
> Waltham, MA 02453<br>
> <br>
> <br>
> _______________________________________________<br>
> x3d-public mailing list<br>
> <a href="mailto:x3d-public@web3d.org" rel="noreferrer noreferrer" target="_blank">x3d-public@web3d.org</a><br>
> <a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer noreferrer noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
> <br>
<br>
<br>
all the best, Don<br>
-- <br>
Don Brutzman  Naval Postgraduate School, Code USW/Br       <a href="mailto:brutzman@nps.edu" rel="noreferrer noreferrer" target="_blank">brutzman@nps.edu</a><br>
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149<br>
X3D graphics, virtual worlds, navy robotics <a href="http://faculty.nps.edu/brutzman" rel="noreferrer noreferrer noreferrer" target="_blank">http://faculty.nps.edu/brutzman</a><br>
<br>
<br>
_______________________________________________<br>
x3d-public mailing list<br>
<a href="mailto:x3d-public@web3d.org" rel="noreferrer noreferrer" target="_blank">x3d-public@web3d.org</a><br>
<a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer noreferrer noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
</blockquote></div>