[x3d-public] [Remaining Work] X3dToPython.xslt, BooleanSequencer keyValue
John Carlson
yottzumm at gmail.com
Mon Jul 4 19:25:02 PDT 2022
Code in question in X3dToPython.xslt, I think, for MFBool's.
<xsl:when test="($x3dType = 'MFBool')">
<!-- Python boolean values are True and False,
comma-separated list -->
<xsl:value-of
select="translate(translate(translate(string($x3dValue),'f','F'),'t','T'),'
',',')"/>
</xsl:when>
Spaces are translated to ',', i think, to "true, false" in XML gets
translated to "True,,False" in Python.
I don't know how to fix this yet (I'm an XSLT plebe), except fix the XML so
Python will work okay. Maybe we should put a feature request into Saxon or
ask for help?
At this point, my suggestion would be to fall back to some kind of regular
expression replacement?
Or what I would do in sed, like:
s/,+/,/g
and
s/ +/ /g
between SFBools
One may wish to put \s or \S , from more advanced regular expressions, and
only allow one comma between SFBools in the MFBool.
I don't know if XSLT supports any of this. Check out this table for XSLT
2.0? Is this accurate?
16.4 Using Regular Expressions | Learning XSLT (flylib.com)
<https://flylib.com/books/en/2.424.1.122/1/>
Did a little googling, found this:
regex - XSLT + regular expression replace - Stack Overflow
<https://stackoverflow.com/questions/35840063/xslt-regular-expression-replace>
(analyze-string)
Perhaps a few of us could attend an advanced XSLT course?
Maybe we could have a learning session? I only see one analyze-string in
our XSLT code base.
Could be a big win, would be my guess.
Or we could use SNOBOL or its derivative, Icon. Icon (programming language)
- Wikipedia <https://en.wikipedia.org/wiki/Icon_%28programming_language%29>
(see
"Dialects" and "Influenced" for additional features, some 3D).
I studied Icon in school, and it was a good language, I didn't run into any
snafu's with our problem set solutions.
I would recommend Icon over XML, XSLT, Python and JavaScript, if anyone
cares, at least for text processing. I didn't do 3D with Icon.
John
On Mon, Jul 4, 2022 at 8:18 PM John Carlson <yottzumm at gmail.com> wrote:
> Trying to help...For MFBool in X3d tooltips, perhaps rephrase whitespace
> as below, for both XML, JSON and Python (and perhaps others).
>
> *Hint:* a single comma character is allowed as whitespace between
> individual SFBool values in the list.
>
> Sorry, I apologize for bringing up MFStrings. I was in the wrong.
>
>
>
> On Mon, Jul 4, 2022 at 7:53 PM John Carlson <yottzumm at gmail.com> wrote:
>
>> If commas are not allowed in XML for MFBool, then Holger needs to change
>> her particle system code.
>>
>>
>> On Mon, Jul 4, 2022 at 7:49 PM John Carlson <yottzumm at gmail.com> wrote:
>>
>>> Note: Please clarify MFBool. I will look again at recent emails.
>>>
>>> My understanding is that SFBool values can be separated by /, / comma
>>> followed by space in an MFBool in XML (comma as whitespace). What I'm not
>>> understanding is the Python output from X3dToPython.xslt, which puts out
>>> commas next to each other (comma not as whitespace). See below.
>>>
>>> On Mon, Jul 4, 2022 at 4:56 PM John Carlson <yottzumm at gmail.com> wrote:
>>>
>>>> Note extra commas in MFBool outputs from X3dToPython.xslt and
>>>> X3dToJson.xslt.
>>>>
>>>> On Mon, Jul 4, 2022 at 4:23 PM John Carlson <yottzumm at gmail.com> wrote:
>>>>
>>>>> Note, the following examples are unvalidated. Beware!
>>>>>
>>>>> For example, from:
>>>>> https://raw.githubusercontent.com/create3000/Library/main/Tests/Components/ParticleSystems/BoundedPhysicsModel.x3d
>>>>> <BooleanSequencer DEF='_4'
>>>>> key='0, 0.3, 1'
>>>>> keyValue='true, false'/>
>>>>>
>>>>> And python:
>>>>>
>>>>> BooleanSequencer(DEF='_4',key=[0,0.3,1],keyValue=[True,,False]),
>>>>>
>>>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20220704/f98cd536/attachment.html>
More information about the x3d-public
mailing list