blockly as XML editor

1,783 views
Skip to first unread message

mcswell2001

unread,
Jan 31, 2016, 10:28:04 PM1/31/16
to Blockly
We have an XML schema (RNG) which defines a sort of linguist's programming language for morphology and phonology, and a way to convert an XML grammar description into an FST, thereby creating a morphological parser. What we don't have is an easy way to guide people in building XML-based grammars. I (and several other people) use programmers' editors, and it's been on my plans for a long time to build the CSS etc. that would allow us to use an XML editor like XMLMind (or perhaps oXygen). But I haven't found my round tuit, so that's not done yet.

We just started thinking about teaching students–perhaps in the Middle School (= Junior High) grade range, perhaps in High School, to do this as a way of getting into computer programming. But I fear that even a structured editor like XMLMind might be off-putting to beginners. Something like Blockly seems like it could be a better way to get started, if it could output XML code instead of Javascript.  I don't mean an XML dump that describes a Blockly program, like the XML tab here: https://blockly-demo.appspot.com/static/demos/code/index.html; I mean creating an XML document using Blockly as the editor.

So my question is, has anyone done something like this? That is, what would it take to use Blockly to output an XML document? I presume the schema elements would be represented by different shapes, and lots of “stuff” would get auto-generated. So consider something like this as (part of) the desired output:
    <?xml version=“1.0” encoding=“UTF-8”?>
    <ilr: LanguageData lang=“Tzeltal” script=“Roman” xmlns:ilr=“http:.//blah..blah”>
        <ilr: PhonologicalData>
           <ilr: PhonemeSet>
                <ilr: Phoneme form=“a” xml:id=“ph_a”/>
                <ilr: Phoneme …
Some of that (e.g. the XML header) would be auto-generated by the Blockly converter. The student would need to choose blocks representing each element, including blocks for as many phonemes as needed, and fill in the name of the language, the @form attribute of the phonemes, etc. Our schema has a lot of elements, but simple grammars can be written with a subset.

Is this feasible in Blockly? Is there a guide on how to set something like this up (export to a new programming language).  Or is there some other tool I should be looking at?

   Mike Maxwell

Matthieu Muffato

unread,
Feb 1, 2016, 4:18:42 AM2/1/16
to blo...@googlegroups.com, Leo Gordon
Hi Mike,

+1 here, we have the same wish.

We haven't thought much about the implementation and the configuration
of Blockly, though. We unfortunately don't have the manpower to do this
ourselves, and were starting thinking of having an intern / GSoC student
work on it, but there's no guarantee at the moment. I'd be happy to hear
anyone else's thoughts on the request, and if there are already
implementations out there.

Matthieu
> --
> You received this message because you are subscribed to the Google
> Groups "Blockly" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to blockly+u...@googlegroups.com
> <mailto:blockly+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

--
Matthieu Muffato, Ph.D.
Ensembl Compara and TreeFam Project Leader
European Bioinformatics Institute (EMBL-EBI)
European Molecular Biology Laboratory
Wellcome Trust Genome Campus, Hinxton
Cambridge, CB10 1SD, United Kingdom
Room A3-145
Phone + 44 (0) 1223 49 4631
Fax + 44 (0) 1223 49 4468

mcswell2001

unread,
Feb 3, 2016, 11:44:09 PM2/3/16
to Blockly
Well, Matthieu, it doesn't look like either of us is going to get our wish very soon, at least not if we're dependent on this forum.  And I didn't do any better over on the Scratch forum.

I'm going to see if I can figure something out with the source code...  I'll let you know if I have any luck.

Blake

unread,
Feb 4, 2016, 12:08:48 AM2/4/16
to Blockly
Mike, Matthieu,

I can't say as I have any experience generating XML but I've been working on adding a Java exporter to build an intro to programming tool for the FIRST Robotics Competition, at the high school level.

I am inclined to believe that you could make an XML generator as you describe. If you look at how the block factory works using the type checking functionality I bet you could build a pretty neat tool.

I would encourage you to tinker with the block factory and read the documentation and see if you can generate the blocks that look the way you imagine. Remember that the block factory can't output every type of block so learning the ins and outs of the block description syntax will be helpful.

I tried my hand at constructing a couple of blocks from your tree above:



This presentation might be of interest:

Hope that gives you a start.

Blake




On Wed, Feb 3, 2016 at 11:44 PM, mcswell2001 <max...@umiacs.umd.edu> wrote:
Well, Matthieu, it doesn't look like either of us is going to get our wish very soon, at least not if we're dependent on this forum.  And I didn't do any better over on the Scratch forum.

I'm going to see if I can figure something out with the source code...  I'll let you know if I have any luck.

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.

mcswell2001

unread,
Feb 4, 2016, 12:16:11 AM2/4/16
to Blockly
Thanks, Blake, I'll be looking at how you did that!

Hendrik Diel

unread,
Feb 4, 2016, 8:32:04 AM2/4/16
to Blockly
Hey,

blocky is able to generate code in probably any language one could imagine. The tricky part for XML is it's massive use of hierarchical structures. The way to go here is probably like Blake Bourque showed with his statement blocks. Those would represent a pair of XML tags in wich you can place other. The tags arguments could be configured through text inputs, checkboxes etc on the block itself. Then, when you have your blocks, which can be viewed as the user interface or frontend of you application, you will need the code generators that convert your blocks in XML rather than JavaScript. Blockly is shipped with some other code generators than JavaScript. However XML is not available yet but it's relativ easy to write your own. In case of XLM a standard code generator wouldn't make much sense anyway.

Hope this helps or gives a little bit of an overview at least.

Greetings

Matthieu Muffato

unread,
Feb 22, 2016, 8:24:53 PM2/22/16
to blo...@googlegroups.com
As I was hoping, my organisation has added this project to their GSoC
application, and I would be the mentor. We'll soon here whether this has
caught up some interest. Fingers crossed ;)

Matthieu

On 04/02/16 05:08, Blake wrote:
> Mike, Matthieu,
>
> I can't say as I have any experience generating XML but I've been
> working on adding a Java exporter to build an intro to programming tool
> <http://easyj.team5122.com/> for the FIRST Robotics Competition, at the
> high school level.
>
> I am inclined to believe that you could make an XML generator as you
> describe. If you look at how the block factory works using the type
> checking functionality I bet you could build a pretty neat tool.
> [Block
> Factory](https://blockly-demo.appspot.com/static/demos/blockfactory/index.html)
> [Blockly Docs Type
> Checking](https://developers.google.com/blockly/custom-blocks/type-checks)
>
> I would encourage you to tinker with the block factory and read the
> documentation and see if you can generate the blocks that look the way
> you imagine. Remember that the block factory can't output every type of
> block so learning the ins and outs of the block description syntax will
> be helpful.
>
> I tried my hand at constructing a couple of blocks from your tree above:
> https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#yxyy3w
>
> https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#wa6xco
> <https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#xmjmq2>
>
> https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#56hev5
>
> This presentation might be of interest:
> https://docs.google.com/presentation/d/1Aovpbe0QHM_gFLSj--e7ovgOldanOQO2mWGBh3Ga-dE/edit#slide=id.p
> <https://docs.google.com/presentation/d/1Aovpbe0QHM_gFLSj--e7ovgOldanOQO2mWGBh3Ga-dE/edit#slide=id.p>
>
> Hope that gives you a start.
>
> Blake
>
>
>
>
> On Wed, Feb 3, 2016 at 11:44 PM, mcswell2001 <max...@umiacs.umd.edu
> <mailto:max...@umiacs.umd.edu>> wrote:
>
> Well, Matthieu, it doesn't look like either of us is going to get
> our wish very soon, at least not if we're dependent on this forum.
> And I didn't do any better over on the Scratch forum.
>
> I'm going to see if I can figure something out with the source
> code... I'll let you know if I have any luck.
>
--

krsnaa

unread,
Apr 1, 2016, 2:12:11 PM4/1/16
to Blockly
Mike, I know it's been a couple of months to your original post. Just checking to see if you had found an answer. I just started on a project that extensively uses hierarchical XML files that are 2-3k lines long and using a text editor for it is an exercise in frustration. Blockly would absolutely be PERFECT for this application like you mention above. Wanted to check on any progress to see if I could stand on the shoulder of giants vs reinventing the wheel : >

maxwell

unread,
Apr 2, 2016, 12:34:45 PM4/2/16
to blo...@googlegroups.com
On 4/1/2016 2:12 PM, krsnaa wrote:
> Mike, I know it's been a couple of months to your original post.
> Just checking to see if you had found an answer. I just started on a
> project that extensively uses hierarchical XML files that are 2-3k
> lines long and using a text editor for it is an exercise in
> frustration.

BTW, I use jEdit (http://www.jedit.org/) for editing XML docs. It's
freeware. If you try it, you'll want to install the XML plugin. It's a
bit better than trying to use a plan text editor.

I don't know what XML schema you're using, but if it's an RNG schemas,
another approach would be to write the CSS code that would allow you to
display it nicely, and use a tool like XMLMind
(http://www.xmlmind.com/xmleditor/). We use it at work for editing
DocBook XML documents, and it works quite well--they of course supply
the DocBook schema and CSS, which you'd have to write. But it might be
less work than trying to use Blockly.
--
Mike Maxwell
max...@umiacs.umd.edu
"I cannot believe that our existence in this universe
is a mere quirk of fate, an accident of history, an
incidental blip in the great cosmic drama. Our
involvement is too intimate. The physical species
Homo may count for nothing, but the existence of
mind in some organism on some planet in the universe
is surely a fact of fundamental significance. Through
conscious beings the universe has generated
self-awareness." --Paul Davies

maxwell

unread,
Apr 5, 2016, 5:06:59 PM4/5/16
to blo...@googlegroups.com
On 4/1/2016 2:12 PM, krsnaa wrote:
> Mike, I know it's been a couple of months to your original post. Just
> checking to see if you had found an answer. I just started on a project
> that extensively uses hierarchical XML files that are 2-3k lines long
> and using a text editor for it is an exercise in frustration. Blockly
> would absolutely be PERFECT for this application like you mention above.
> Wanted to check on any progress to see if I could stand on the shoulder
> of giants vs reinventing the wheel :

Only dwarves here.

I got far enough for a proof of concept, which is to say I constructed a
couple XML templates and figured out how to convert the Blockly objects
into real XML. I'll attach the three files that are the proof of
concept; they're based on the files in the Blockley demos/code dir and
blocks dir, and I store them in a subdirectory of the demos/ dir that I
called LanguageSchema (because my application has to do with language).

index.html: You can see what I did to the file if you do a diff between
my index.html file and the one in demos/code.

LanguageSchema.js: based off of blocks/logic.js, loaded by index.html.

code.js: based off of demos/code/code.js (in fact, I haven't removed all
the stuff that's for building Javascript programs with Blockly)

Also in my LanguageSchema dir is a file style.css, but that's unmodified
from the file of the same name in the Blockly code dir.

BTW, there's s.t. very odd: if I open a browser on
LanguageSchema/index.html and click on the LanguageData object on the
left, it displays my LanguageData template in the editing area. In
principle, I should then be able to click on the "XML" tab and produce
an XML output. But unless I actually mouse the template and move it
slightly, this doesn't work. I'm not sure why.
code.js
index.html
LanguageSchema.js
Reply all
Reply to author
Forward
0 new messages