Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6765063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:40:05+00:00 2026-05-26T14:40:05+00:00

I’m trying to write an XML grammar for OkudaKit. I noticed that the bundled

  • 0

I’m trying to write an XML grammar for OkudaKit. I noticed that the bundled HTML grammar works for simple XML, but fails with namespaced elements or attributes, so the first thing I want to do is add support for these. Using the HTML grammar as a template, I defined ns and then added it to tagName and attrName:

@multiLineComments = '<!--' '-->';
@commentState = '<';
@commentState.fallbackState = delimitState;

@delimitedString = '<?' '?>' nil;
@delimitedString = '<!DOCTYPE' '>' nil;
@delimitState.fallbackState = symbolState;

@start          = any*;
any             = element | text | doctype | pi | comment;

pi              = DelimitedString('<?', '?>');

doctype         = DelimitedString('<!DOCTYPE', '>');
element         = emptyTag | startTag elementContent* endTag;
elementContent  = element | text | comment | pi;
text            = /[^<]+/;

emptyTag        = lt tagName attr* fwdSlash gt;
startTag        = lt junk? tagName attr* gt;
endTag          = lt fwdSlash tagName gt;

ns              = Word colon;

tagName         = ns? Word;

attr            = attrName eq attrValue;
attrName        = ns? Word;
attrValue       = QuotedString;

eq              = '=';
lt              = '<';
gt              = '>';
fwdSlash        = '/';
colon           = ':';

comment         = Comment;

Seems like it should work (if I understand the “?” properly, which I probably don’t) but the output is messed up. Below is my test document:

<?xml version="1.0" encoding="utf-8"?>
<test cats:dogs="television">
    <peas vegetable="box" >
        <orange />
        <!-- the following makes no sense -->
        <blue lion:mouse="cold"/>
        <red car:desk="apple">
            < envelope></ envelope>
            <![CDATA[lorem ipsum]]>
            <dwarves>
                <dwarf>Sleepy</dwarf>
                <dwarf>Dopey</dwarf>
            </dwarves>
        </red>
    </peas>
</test>

And this is what it looks like after my broken grammar mangles it (ignore the formatting, that’s NSXMLDocument’s pretty printing):

<?xml version="1.0" encoding="utf-8"?>
< :cats=dogstest"television">
    < =vegetable"box"peas>
        <>orange</>orange
        <!-- the following makes no sense -->
        < :lion=mouseblue"cold"></>blue
        < :car=deskred"apple">&lt; envelope>&lt;/ envelope> lorem ipsum<>dwarves
                <>dwarfSleepy</>dwarf
                <>dwarfDopey</>dwarf
            </>dwarves
        </>red
    </>peas
</>test

I’m interpreting the “?” to mean “optional” but I think that’s wrong. I didn’t find it covered in the ParseKit grammar guide.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:40:06+00:00Added an answer on May 26, 2026 at 2:40 pm

    Developer of OkudaKit/ParseKit here. I’ve fixed the root problem which was causing the issue you ran into.

    My OkudaKit HTML grammar didn’t support CDATA or QNames. I have enhanced the HTML Grammar in the OkudaKit SVN repo (in trunk). Please update your working copy and you’ll see the fix. The HTML grammar should now serve your needs (let me know if you run into issues).

    Two Final things/tricks to keep in mind (which I had forgotten myself):

    1. The Grammar Productions for which you define CSS Rules MUST be Terminal Grammar Productions.

      Here’s some examples of Teminal Productions (hint: they don’t point to other non-terminal productions):

      colon = ':';
      prefix = Word;
      comment = Comment;
      

      These are not Terminal Productions:

      qName = qualifiedName | unqualifiedName;
      @start = any*;
      
    2. ALL Terminal Productions in your Grammar MUST have CSS Rules defined in the CSS file.

    The reason your first attempt at a fix didn’t work is that you were not respecting the two rules above. When you don’t follow those two rules, the output gets borked/reordered in strange ways.

    Very sorry, I know this information is not included anywhere with OkudaKit, so there’s no way you could have known. I will try to fix that in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am doing a simple coin flipping experiment for class that involves flipping a
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.