You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Piotr Zarzycki <pi...@gmail.com> on 2022/05/12 15:37:15 UTC

Displaying text in MXML

Hi guys,

I'm fighting with problem of displaying text inside component in MXML. I
have following text and a lot of similar one:

"for machine in $(pfexec VBoxManage list runningvms | cut -f 1 -d ' ' | sed
's/&quot;//g'); do pfexec VBoxManage showvminfo $machine | grep
&quot;Memory size:&quot; | sed 's/^.* \([0-9]*\)MB$/\1/g' ; done | awk
'{sum+=$1/1024.0}END{printf &quot;Running:  %d GB\n&quot;, sum}'; for
machine in $({ pfexec VBoxManage list vms | grep -v Template; pfexec
VBoxManage list runningvms; } | sort | uniq -u | cut -f 1 -d ' ' | sed
's/&quot;//g'); do pfexec VBoxManage showvminfo $machine | grep
&quot;Memory size:&quot; | sed 's/^.* \([0-9]*\)MB$/\1/g' ; done | awk
'{sum+=$1/1024.0}END{printf &quot;Other:  %d GB\n&quot;, sum}';"

I need to literally display it without changes. I would like to do that
inside MXML, no var declaration etc. I was experimenting with CDATA, but
compiler still complains about some literals inside this text instead
ignoring it.

Does anyone have an experience with this ?

Thanks,
-- 

Piotr Zarzycki

Re: Displaying text in MXML

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Yes, and it probably is.  You can run the MXML file through an XML validator to check.

But then the data in the CDATA gets handed to the compiler, and I don't remember our rules for string-based properties.  Either you have to escape them to also be Java-compiler-compatible, or the MXML parser in the compiler is supposed to escape incoming strings.

If you can run a test using Flex it might answer that question.

I think you have to escape strings and use backslash-n for linefeeds, for example.  There might be some online Java string escape converters if the rule is that you have to escape it yourself.

HTH,
-Alex

On 5/13/22, 2:07 AM, "Piotr Zarzycki" <pi...@gmail.com> wrote:

    Shouldn't CDATA be ignored by compiler ? At least what is inside of it ?

    czw., 12 maj 2022 o 17:37 Piotr Zarzycki <pi...@gmail.com>
    napisał(a):

    > Hi guys,
    >
    > I'm fighting with problem of displaying text inside component in MXML. I
    > have following text and a lot of similar one:
    >
    > "for machine in $(pfexec VBoxManage list runningvms | cut -f 1 -d ' ' |
    > sed 's/&quot;//g'); do pfexec VBoxManage showvminfo $machine | grep
    > &quot;Memory size:&quot; | sed 's/^.* \([0-9]*\)MB$/\1/g' ; done | awk
    > '{sum+=$1/1024.0}END{printf &quot;Running:  %d GB\n&quot;, sum}'; for
    > machine in $({ pfexec VBoxManage list vms | grep -v Template; pfexec
    > VBoxManage list runningvms; } | sort | uniq -u | cut -f 1 -d ' ' | sed
    > 's/&quot;//g'); do pfexec VBoxManage showvminfo $machine | grep
    > &quot;Memory size:&quot; | sed 's/^.* \([0-9]*\)MB$/\1/g' ; done | awk
    > '{sum+=$1/1024.0}END{printf &quot;Other:  %d GB\n&quot;, sum}';"
    >
    > I need to literally display it without changes. I would like to do that
    > inside MXML, no var declaration etc. I was experimenting with CDATA, but
    > compiler still complains about some literals inside this text instead
    > ignoring it.
    >
    > Does anyone have an experience with this ?
    >
    > Thanks,
    > --
    >
    > Piotr Zarzycki
    >


    -- 

    Piotr Zarzycki


Re: Displaying text in MXML

Posted by Edward Stangler <es...@bradmark.com>.
Yes, CDATA should work.  The following works in Flex:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx">

    <mx:TextArea width="500" height="500">
        <mx:text>
<![CDATA[
"for machine in $(pfexec VBoxManage list runningvms | cut -f 1 -d ' ' | sed
's/&quot;//g'); do pfexec VBoxManage showvminfo $machine | grep
&quot;Memory size:&quot; | sed 's/^.* \([0-9]*\)MB$/\1/g' ; done | awk
'{sum+=$1/1024.0}END{printf &quot;Running:  %d GB\n&quot;, sum}'; for
machine in $({ pfexec VBoxManage list vms | grep -v Template; pfexec
VBoxManage list runningvms; } | sort | uniq -u | cut -f 1 -d ' ' | sed
's/&quot;//g'); do pfexec VBoxManage showvminfo $machine | grep
&quot;Memory size:&quot; | sed 's/^.* \([0-9]*\)MB$/\1/g' ; done | awk
'{sum+=$1/1024.0}END{printf &quot;Other:  %d GB\n&quot;, sum}';"
]]>
        </mx:text>
    </mx:TextArea>
</mx:Application>


The only thing you have to escape in CDATA is "]]>".  (You would replace
it with "]]]]><![CDATA[>".)


I've opened compiler issue #213.  The problem is that it thinks things
like "{sum}" are data binding.  (And newlines are being lost, too, if
you have other text.)



On 5/13/2022 4:08 AM, Piotr Zarzycki wrote:
> Shouldn't CDATA be ignored by compiler ? At least what is inside of it ?
>
> czw., 12 maj 2022 o 17:37 Piotr Zarzycki
> napisał(a):
>
>> Hi guys,
>>
>> I'm fighting with problem of displaying text inside component in MXML. I
>> have following text and a lot of similar one:
>>
>> "for machine in $(pfexec VBoxManage list runningvms | cut -f 1 -d ' ' |
>> sed 's/&quot;//g'); do pfexec VBoxManage showvminfo $machine | grep
>> &quot;Memory size:&quot; | sed 's/^.* \([0-9]*\)MB$/\1/g' ; done | awk
>> '{sum+=$1/1024.0}END{printf &quot;Running:  %d GB\n&quot;, sum}'; for
>> machine in $({ pfexec VBoxManage list vms | grep -v Template; pfexec
>> VBoxManage list runningvms; } | sort | uniq -u | cut -f 1 -d ' ' | sed
>> 's/&quot;//g'); do pfexec VBoxManage showvminfo $machine | grep
>> &quot;Memory size:&quot; | sed 's/^.* \([0-9]*\)MB$/\1/g' ; done | awk
>> '{sum+=$1/1024.0}END{printf &quot;Other:  %d GB\n&quot;, sum}';"
>>
>> I need to literally display it without changes. I would like to do that
>> inside MXML, no var declaration etc. I was experimenting with CDATA, but
>> compiler still complains about some literals inside this text instead
>> ignoring it.
>>
>> Does anyone have an experience with this ?
>>
>> Thanks,
>> --
>>
>> Piotr Zarzycki
>>
>


Re: Displaying text in MXML

Posted by Piotr Zarzycki <pi...@gmail.com>.
Shouldn't CDATA be ignored by compiler ? At least what is inside of it ?

czw., 12 maj 2022 o 17:37 Piotr Zarzycki <pi...@gmail.com>
napisał(a):

> Hi guys,
>
> I'm fighting with problem of displaying text inside component in MXML. I
> have following text and a lot of similar one:
>
> "for machine in $(pfexec VBoxManage list runningvms | cut -f 1 -d ' ' |
> sed 's/&quot;//g'); do pfexec VBoxManage showvminfo $machine | grep
> &quot;Memory size:&quot; | sed 's/^.* \([0-9]*\)MB$/\1/g' ; done | awk
> '{sum+=$1/1024.0}END{printf &quot;Running:  %d GB\n&quot;, sum}'; for
> machine in $({ pfexec VBoxManage list vms | grep -v Template; pfexec
> VBoxManage list runningvms; } | sort | uniq -u | cut -f 1 -d ' ' | sed
> 's/&quot;//g'); do pfexec VBoxManage showvminfo $machine | grep
> &quot;Memory size:&quot; | sed 's/^.* \([0-9]*\)MB$/\1/g' ; done | awk
> '{sum+=$1/1024.0}END{printf &quot;Other:  %d GB\n&quot;, sum}';"
>
> I need to literally display it without changes. I would like to do that
> inside MXML, no var declaration etc. I was experimenting with CDATA, but
> compiler still complains about some literals inside this text instead
> ignoring it.
>
> Does anyone have an experience with this ?
>
> Thanks,
> --
>
> Piotr Zarzycki
>


-- 

Piotr Zarzycki