« first day (2267 days earlier)      last day (681 days later) » 

00:05
Continuing the XHTML/XML thread, I wrote a function for translating XML into a namespace. It's not perfect yet and doesn't handle attributes, but it is usable for getting a namespace from a (standard-compliant) HTML document.
      html
<html>
 <body>
  <h2>
   Hello,
  </h2>
  <h2>
   World!
  </h2>
 </body>
</html>
      ⎕JSON Xmln html
{"html":{"body":[{"h2":"Hello,"},{"h2":"World!"}]}}
      (Xmln a).html.body.h2
 Hello,  World!
 
1 hour later…
01:24
@finooiigee That's cool. Is there any particular reason why you're wanting to represent trees as a namespace hierarchy instead of some inverted table with depth information or whatnot?
01:46
Because . syntax is convenient
 
2 hours later…
04:04
@finooiigee There can only be one RIDE connection at a time, so it would preclude using RIDE.
@finooiigee "from a (standard-compliant) HTML document" — you mean XHTML? I would expect it to fail on common things like <br> and <img>
 
1 hour later…
05:12
@Adám Right, those are valid. So are <br /> and <img />. One thing it can't handle is <style> and <script> elements
@finooiigee Why not? style and script are normal elements, are they not?
Oops - I meant only <script>. If the content of the script tag contains valid HTML - ⎕XML will parse it, which can create an invalid dom
Barring that you can write fully functional HTML in a XHTML compatible manner
@B.Wilson It is a good question. It shouldn't be too hard to implement . for the usual format of ⎕XML - an inverted table with depth information. Another reason to generate namespaces is that ⎕JSON is a useful intermediary format
 
4 hours later…
09:22
@roman-kashitsyn I've made an issue to try and make this more clear at some point github.com/Dyalog/APLCourse/issues/61
@finooiigee This is awesome! I guess my last curiosity is how it performs compared to Abacus' recursion - obviously notwithstanding lack of features.
 
1 hour later…
10:42
@finooiigee ⎕JSON⍠'M' will give you a table with depth info, so you could stay in inverted-table land. I was mostly just wondering if you had a specific problem in hand where hierarchies of namespaces gave you particular ergonomics not afforded by an inverted table.
@dzaima Someone recently asked me if I could hack together a certain prototype Android app, and I thought it'd be fun to do it in APL. I'm aware that your APL implementation has an android app, but is it relatively easy to do Java interop for GUI element hooks and the like? I'll probably want to look at your code, but just wanted to get a quick sanity check before diving in.
11:16
@B.Wilson Not available for use yet, but might still enthuse you: dyalog.tv/Dyalog16/?v=lVA9Ke6Vy_Y
 
2 hours later…
12:56
@finooiigee the trick is to use CDATA literal to embed JS so it can be valid XML stackoverflow.com/questions/66837/…
Most of the HTML to XML conversion tools are aware of that
Nice, thanks
At least I know HTML tidy can parse invalid or valid HTML to valid XHTML and do the proper script element escaping
@RikedyP For 181 rows of (⎕XML) - from a 9000 character HTML document, it takes 4ms to convert to a namespace - which although small is still surprising to me. It should scale linearly - and I think it could be written in a much more performant way.
I'll look into abacus
@B.Wilson namespaces are easier to use, and lead to more straight-forward code. But it's not too significant. I wouldn't mind writing 'h2' mdot 'body' mdot html
Or ⊃mdot/'h2' 'body',⊂html
13:31
Then I guess you will reinvent XPath
14:27
@B.Wilson dzaima/APL doesn't provide anything for allowing to invoke Java things from APL, so you'd be stuck doing most things in Java. It does have a Processing integration, which'd allow you to draw rectangles & circles & stuff, but no native UI stuff
and it's all very very incomplete
 
9 hours later…
23:01
@finooiigee Hrm. Not sure I agree. In some limited cases, like your html.body.h2 example, the syntax looks nice, but even ignoring the fact that it throws away the ordering information on sibling nodes, the ergonomics of semantic operations over the whole tree can be pretty bad.
For example, how would you capitalize all your h2 elements? Or what about grabbing the content of any div that has a particular annotation?
Using named-column tables, seems to put all these problems within reach of
fast, normal APL operations. E.g.
    {p[⍵]←⍺[⍺⍸⍵]}/⊢∘⊂⌸d⊣p←⍳≢⊃d n v t←↓⍉⎕json⍠'M'⊢'{...}'
Then your (Xmnl a).html.body.h2 becomes something like n[∪p∘I⊢p∘I⍸n≡¨⊂'h2']≡,⊂'body', or even v/⍨n∘.≡⊂'h2', depending on exactly what you're wanting to say.
IMO, the latter two sentences more directly surface the intent of what you're wanting to do, whereas html.body.h2 doesn't tell me whether you actually really care about h2 being a child of body or whether you are enforcing html to be unique at the top.

« first day (2267 days earlier)      last day (681 days later) »