[x3d-public] x3d case correction tool

Andreas Plesch andreasplesch at gmail.com
Wed Nov 4 13:23:42 PST 2015


After I got with xmlsh a working xslt v.2 processor (xsltproc only supports
v.1), I could reproduce the
table
http://www.web3d.org/x3d/stylesheets/X3dElementsAttributesLowerCaseTable.txt
using Don's stylesheet and the x3d 3.3 schema . Looking at the table more
closely, it has entries for lowercase elements such as appearance or
material (in the second column). The source of these entries are some
<xs:appinfo> elements in the schema, for example for the Shape element,
which list these elements with a lowercase name attribute:

http://www.web3d.org/specifications/X3dSchemaDocumentation3.3/x3d-3.3_Shape.html#Link184

(scroll to annotation) (or grep name="appearance" in the schema file)

These xs:appinfo within xs:annotation are there presumably only for
documentation purposes and not for validation purposes ? As such they may
have flown under the radar ?

Or perhaps xs:appinfo has some requirement to list elements with the name
in lowercase ?

So I would like to exclude those element matches in the xslt style sheet.
Currently they are selected by

 select="//xs:element[string-length(@name) > 0]"

but now I would like to modify the XPath to exclude matches if the parent
element is xs:appinfo.

Apologies if this is a trivial XPath question but any hint is appreciated.

-Andreas



On Tue, Nov 3, 2015 at 4:57 PM, Andreas Plesch <andreasplesch at gmail.com>
wrote:

> Thanks for the lower case table stylesheet at
> http://www.web3d.org/x3d/stylesheets/X3dElementsAttributesLowerCaseTableConstruction.xslt
>
> It is more manageable for a xslt language novice. I think the idea would
> be to use it as a basis to come up with a lowercase/anycase to x3d
> camelCase xslt replacement rule style sheet.
>
> I think I would try first to generate separate lists for elements and
> attributes which the style sheet effectively already does, in sequence.
>
> I have xstlproc installed: http://xmlsoft.org/XSLT/xsltproc2.html . Let's
> see how it works. What other processors are recommended ?
>
> The use case for me is that it required quite a bit of repetitive effort
> to get x3d output generated by the vrmath2.net editor such as
>
>
> https://vrmath2.net/embed/?url=/sites/default/files/user/u342/x3d/helical_gears_smooth_opt.x3d
>
> into a conforming format so that use of x3d-edit and xj3d would start to
> make more sense. A lot of that effort was just to get the case correct.
> Most of the remaining effort was to get rid of the nonconforming attributes
> such as id. (Perhaps there is way to keep nonconforming attributes around
> as comments).
>
> So I was just envisioning a long, generated sed script with expressions
> such as s/<elementname *>/<Elementname>/ or such and similar for closing
> and empty tags, as well as attributes.
>
> I think this would go a long way to reformat a nonconforming x3d document
> towards conforming.
>
> I may also give xmlsh at http://www.xmlsh.org/HomePage a try. It seems
> appealing to me. (I just saw that it has some json support). Any experience
> with it ?
>
> Since html5 is (in general?) not case sensitive, prose on x3d vocabulary
> within a html5 context would presumably be about what the recommended,
> case-sensitive form is for reasons of validation, compatibility with xml
> and other contexts, and general readability versus what the presumably
> accepted but discouraged case-insensitive form is. Or is it something else
> it should address ?
>
> Andreas
>
>
>
>
>
> On Tue, Nov 3, 2015 at 2:10 PM, Don Brutzman <brutzman at nps.edu> wrote:
>
>> Thanks for the good thinking.
>>
>> Some time ago, when first looking at HTML lower-case elements and X3DOM
>> integration, there was good dialog on the mail lists.  No doubt available
>> in the archives.
>>
>> It would appear that both forms (CamelCase and lowercase/miXedcAsE) are
>> desirable for X3D authors depending on their html publication context.
>>
>> At that stage I created a stylesheet that creates a table for producing
>> lower-case version of X3D element names and attributes.  It walks the X3D
>> schema in a manner similar to what you are suggesting.
>>
>> http://www.web3d.org/x3d/stylesheets/
>> http://www.web3d.org/x3d/stylesheets/X3dElementsLowerCaseTable.html
>> http://www.web3d.org/x3d/stylesheets/X3dAttributesLowerCaseTable.html
>>
>> http://www.web3d.org/x3d/stylesheets/X3dElementsAttributesLowerCaseTable.txt
>>
>> http://www.web3d.org/x3d/stylesheets/X3dElementsAttributesLowerCaseTableConstruction.xslt
>>
>> Just tuned them up a little.  Might need more precise filtering to avoid
>> duplicates, etc.
>>
>> Hopefully this is useful.
>>
>> As you point out, the X3D Tidy stylesheet looks at this task too.
>>
>> http://www.web3d.org/x3d/stylesheets/X3dTidy.html
>> http://www.web3d.org/x3d/stylesheets/X3dTidy.xslt
>>
>> At this point, it might be good to articulate any use cases and the
>> relevant HTML5 prose on case sensitivity.
>>
>> Open source.  All suggestions, improvements or additions welcome.
>>
>>
>> On 11/3/2015 9:34 AM, Andreas Plesch wrote:
>>
>>> Since the idea of having a x3d document which is conforming as much as
>>> possible is attractive, I am thinking of a tool which corrects element
>>> names and attribute names to their correct case sensitive spelling. Is
>>> there such a tool ?
>>>
>>> In principle I think it could work by:
>>> 1) extract all element and attribute names from the .dtd and/or schema
>>> 2) go through all elements (recursively) in (nonconforming) x3d document
>>> 2a)  normalize element name to lower-case and see if there is a
>>> corresponding normalized node name in dtd
>>> 2b) if there is replace with correct, case sensitive element name
>>>    if not flag as unknown (or ignore, optionally eliminate)
>>> 2c) do the same for all used attribute names
>>>
>>> This would work for most if not all names since they can all (most?) be
>>> distinguished in a case insensitive manner.
>>>
>>> The tool of choice would be a xsl style sheet which may have to be
>>> generated by another stylesheet which processes the .dtd/schema. What would
>>> be other strategies (going through json) ? How would one go about this in
>>> more detail ? Perhaps the x3d-tidy.xsl style sheet is a starting point ? It
>>> looks daunting.
>>>
>>> However, I would probably start much more straightforwardly by looking at
>>> http://www.web3d.org/specifications/X3dDoctypeDocumentation3.3.html and
>>>
>>> http://www.web3d.org/specifications/X3dSchemaDocumentation3.3/x3d-3.3.html
>>> to assemble a list and then use unix tools such as sed/awk and such
>>> to transform the x3d. What is used to generate the above documentation
>>> from the .dtd/xsd ?
>>>
>>> Any input much appreciated,
>>>
>>> Andreas
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> x3d-public mailing list
>>> x3d-public at web3d.org
>>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>>
>>>
>>
>> all the best, Don
>> --
>> Don Brutzman  Naval Postgraduate School, Code USW/Br
>> brutzman at nps.edu
>> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA
>> +1.831.656.2149
>> X3D graphics, virtual worlds, navy robotics
>> http://faculty.nps.edu/brutzman
>>
>
>
>
> --
> Andreas Plesch
> 39 Barbara Rd.
> Waltham, MA 02453
>



-- 
Andreas Plesch
39 Barbara Rd.
Waltham, MA 02453
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20151104/953dd5a3/attachment.html>


More information about the x3d-public mailing list