using clarion queues to process XML ? anythoughts 
Author Message
 using clarion queues to process XML ? anythoughts

i was wondering if processing xml into a recursive queue would be a simple
way of getting at xml files using some clarion code in a dll.

say a set of functions like this. which spared the xmls tags into a recurive
queue structure.

has anyone mucked about with this sort of thing?

this would mean no file structure just open the text files and go.

TagSetOpen              (long TagSetName),Pascal
TagNext                 (*long NextTagNode),Pascal
TagFields               (*long TagFields),Pascal
TagField                (*long TagFieldName,*long TagFieldValue)
TagFree                 (),pascal

many thanks steve



Sun, 06 Nov 2005 12:50:24 GMT  
 using clarion queues to process XML ? anythoughts
www.thinkdata.com XMLFuse

Thanks.

Kelvin Chua
SINGAPORE


Quote:
> i was wondering if processing xml into a recursive queue would be a simple
> way of getting at xml files using some clarion code in a dll.

> say a set of functions like this. which spared the xmls tags into a
recurive
> queue structure.

> has anyone mucked about with this sort of thing?

> this would mean no file structure just open the text files and go.

> TagSetOpen              (long TagSetName),pascal
> TagNext                 (*long NextTagNode),Pascal
> TagFields               (*long TagFields),Pascal
> TagField                (*long TagFieldName,*long TagFieldValue)
> TagFree                 (),pascal

> many thanks steve



Sun, 06 Nov 2005 13:15:20 GMT  
 using clarion queues to process XML ? anythoughts
i was thinking about a non interfaced solution, in fact ive already started
work on it.

what i want is one that uses abstract code with no com.

its for local file parsing only into a queue, so it can displayed directly
into a Control, or use directly in code.

no com required.

i was wondering if someone had done this with clarion queues?

thanks steve



Sun, 06 Nov 2005 13:42:49 GMT  
 using clarion queues to process XML ? anythoughts
I see..

Jim Kane...I understand he did something...

Thanks.

Kelvin Chua
SINGAPORE


Quote:
> i was thinking about a non interfaced solution, in fact ive already
started
> work on it.

> what i want is one that uses abstract code with no com.

> its for local file parsing only into a queue, so it can displayed directly
> into a Control, or use directly in code.

> no com required.

> i was wondering if someone had done this with clarion queues?

> thanks steve



Sun, 06 Nov 2005 13:47:11 GMT  
 using clarion queues to process XML ? anythoughts
andrews product looks great, no we havnt got anything yet.

but andrews products is more then we need for tomorrows test.

so we are writting something tonight.

thanks for pointing us there, we dont have an interface at all.

in the last hour we have checked out andrews product, but we are in New
Zealand and need to pass clarion data to VB and back again.

so we are now writing some dirty test code

something like this. it shoudl be finished in about an hour, should work

 ALen = len(TagText)
    Loop
         CPos += 1
         If Cpos >  ALen
            Break
         End
         CToken = TagText[ Cpos : Cpos ]
         Case CToken
            Of '<'
            If TagBracketOpen = False                                  ! If
Tag Open Not found / Start of Tag
              TagBracketOpen = Cpos                                    !
Start of Tag
              TagBracketClose = TagNextToken(TagText,'>',Cpos)         !
Find tag Close / Extract Tag Name
              If TagBracketOpen > False AND TagBracketClose > False    ! Tag
Found / Extract tag name
                 SubTagName = TagText[ TagBracketOpen + 1 :
TagBracketClose - 1 ]
              End
            Elsif TagBracketOpen > False And TagBracketClose > False And
DelimitTagBracketOpen = False   !
                  ! Is this the start of the Tag delimiter
                  DelimitTagBracketOpen = Cpos
                  ! Search for Tag delimiter
                  Tagdelimit = TagNextToken(TagText,'/',Cpos)         ! Tag
delimiter
                  If Tagdelimit > False                               ! Yes
found
                     DelimitTagBracketClose =
TagNextToken(TagText,'>',Tagdelimit)         ! Tag delimiter
                     If DelimitTagBracketClose > False                !
Found delimited Tag all in the one search
                        ! Extract Field Tag Value
                     End
                  End

            End
            Of '/'
            If TagBracketOpen > False And TagBracketClose > False And
DelimitTagBracketOpen > False
               Tagdelimit = Cpos
               TagBracketClose = TagNextToken(TagText,'>',Cpos)        !
Find End Tag
               If TagBracketClose > False
                  ! Extract field Tag Value
               End
            End

            Of '>'
            If TagBracketOpen > False And TagBracketClose = False And
DelimitTagBracketOpen = False AND |
                DelimitTagBracketClose = False AND Tagdelimit = False
                TagBracketClose = Cpos
                ! End of start of Tag, search ahead didnt find it.
                Return('')  ! So badly formatted so us
            End
         End
         ! Test for field found / Else badly formatted tag set
    End
    If TagBracketOpen > False And TagBracketClose > False And
DelimitTagBracketOpen > False AND |
       DelimitTagBracketClose > False AND Tagdelimit > False Then
       ! This was a Complete tag set, probably a field in a record set, lets
get the next line and see whats there
       ! Add to the List Node
       Add(TagList.ASubSet)
       If TagNextLine() = False
          NodeTagName = TagFields(ALocalTable.ALineItem,'',TagList.ASubSet)
! Process Next Record but same List

!SubTagRecords              Long           ! Records in next Set
!TagNode                    Byte           ! This is the start of a Tag Node
set
!TagFields                  Byte           ! This is a Tag Field Record with
info
!ATagName                   String(55)     ! Name of Tag set
!ATagField                  String(255)    ! The Name Record Info

        If Upper(TagList.ATagName) = upper(NodeTagName)
           Return(TagList.ATagName)  ! Return this Node Name as Complete
         End
      End
     Elsif TagBracketOpen > False And TagBracketClose > False And
DelimitTagBracketOpen = False
         TagList.ASubSet &= New(TagSets)    ! Found Open brackets for a Node
Tag / new List for this node and call down the tree
         Clear(TagList.ASubSet)
         NodeTagName = TagFields(ALocalTable.ALineItem,'',TagList.ASubSet)
! Process Next Record but same List

     Elsif TagBracketOpen = False And TagBracketClose = False And
DelimitTagBracketOpen > False AND |
       DelimitTagBracketClose > False AND Tagdelimit > False Then
       ! Did we find a Closing Tag and its no opening tag, if so we need to
return up the tree with the tag name
       ! and see if the closes the tag above.
       Return(SubTagName)



Sun, 06 Nov 2005 14:09:43 GMT  
 using clarion queues to process XML ? anythoughts
Steve,

Quote:
> i was wondering if someone had done this with clarion queues?

I am working in XML with "just" clarion code since a while, but my code is
relatively speaking very simple, as it is not generic, and I parse for
expected "fields names".

If I understand what you are doing, it is writing a "generic" parser in
clarion code. I guess that should be possible, but it might quickly get very
complex, because of the attributes. And even once you have achieved that,
you'll still need to check the document against its DTD or schema, and that
in itself is a whole other story....

Anyway, I could be interested in exchanging with you, as a solution not
needing to interface with anything would be a great thing for Clarion/XML.

Bernard



Sun, 06 Nov 2005 22:10:09 GMT  
 using clarion queues to process XML ? anythoughts
sure , today its just some code to read XML into a Noded Tree.

We are also working on porting a generic parser to clarion to replace
components in our Expert Rules system.

So we will soon have a generic parser ready to go.

Today we will test the basic tree node system as a generic class callable
from any langauge.

Here are a list of the commands since last night.

Check with me on friday your time/ saturday and you will able able to parse
the tree.

a loadable syntax checker will come with the introduction of the production
parser, but we wont have that ready till later next week.

this software must run with other software such as DOT net and VB

so all interfaces are like this.

! Generate XML File
        TagSet                  (),pascal
        TagAdd                  (long MyNameTag),pascal
        TagAddContentLine       (long TagNode,long TagContentLine),pascal
        TagGenerate             (long FileName),pascal
        TagGenerateNode         (AQueue ATagSet),pascal
        TagDelete               (AQueue ASubTag),pascal
        ! Read XML
        TagSetOpen              (long TagSetName),pascal
        TagSetFind              (long TagName),pascal
        TagNextLine             (),Proc,Long
        TagNextToken            (String TagLine,String SearchForNext,Long
TokenPos),Proc,Long
        TagFields               (String TagText,String TagName,TagSets
TagList),proc,string
        TagClose                (),Pascal
        !TagNext                 (*long NextTagNode),Pascal
        !TagFields               (*long TagFields),Pascal
        !TagField                (*long TagFieldName,*long TagFieldValue)
        !TagFree                 (),pascal

cheers steve



Mon, 07 Nov 2005 06:45:11 GMT  
 using clarion queues to process XML ? anythoughts
production parsing test underway using this as an early example, this
portion of the descent parser just handles the simple stuff, the function
and assignments are handled by getexpression, not gettoken.

ThisExpression    &= New(ExpressionClass)
        ThisExpression.Init

ThisExpression.AnExpression.AddItem('(A+100-(B*C)/2)*(3444.22-(34*432)/100)'
)
        ThisExpression.getToken
        ThisExpression.Kill
        Dispose(ThisExpression)

the parsing engine without the production descent portion.

xpressionClass.GetToken              Procedure
ASetString   String(255)
    Code
     If len(Clip(Self.AnExpression.GetItem())) = False
       return
    End
    Self.TokenPos = 1
    Self.ParsedExpression.AddItem('')
    Loop While Self.IsWhiteSpace(Self.AnExpression.GetNextChar())
         Self.TokenPos += 1
    End
     Loop Until Self.TokenPos > len(Clip(Self.AnExpression.Getitem()))
    If
InList(Self.AnExpression.GetCharPos(Self.TokenPos),'(',')','*','/','-','+','
^','=') <> False

       ASetString = ''
       Self.ADelimiterType = TT:Delimiters

Self.ParsedExpression.AddItem(Self.AnExpression.GetCharPos(Self.TokenPos))
       ASetString = Self.AnExpression.GetCharPos(Self.TokenPos)
       Self.AssignToken(ASetString,Self.ADelimiterType)
       Self.TokenPos += 1

    ElsIf Self.IsAplhaChar(Self.AnExpression.GetCharPos(Self.TokenPos)) >=
True
          ASetString = ''
          Loop While
Not(Self.Isdelimiter(Self.AnExpression.GetCharPos(Self.TokenPos))) >= True
                Self.ADelimiterType = TT:Variables
               ASetString = Clip(ASetString) &
Self.AnExpression.GetCharPos(Self.TokenPos)

Self.ParsedExpression.AddToItem(Self.AnExpression.GetCharPos(Self.TokenPos))
! Build Variable
               Self.TokenPos += 1
          End
          Self.AssignToken(ASetString,Self.ADelimiterType)

    Elsif Self.IsDigit(Self.AnExpression.GetCharPos(Self.TokenPos)) >= True
          ASetString = ''
          Loop While
Not(Self.Isdelimiter(Self.AnExpression.GetCharPos(Self.TokenPos))) >= True

Self.ParsedExpression.AddToItem(Self.AnExpression.GetCharPos(Self.TokenPos))
! Build Number
               Self.ADelimiterType = TT:Numbers
               ASetString = Clip(ASetString) &
Self.AnExpression.GetCharPos(Self.TokenPos)
               Self.TokenPos += 1
          End
          Self.AssignToken(ASetString,Self.ADelimiterType)

    End
    End

cheers steve



Mon, 07 Nov 2005 08:03:56 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Using CLOCC xml.lisp to print XML in XML format

2. Help on using AWK to process an XML file

3. Article on using Python generators for XML and DOM processing

4. Clarification of Queue Operation / Behavior when using multiple Queues

5. Validation with XML Schemas with Clarion 5.5 and Microsoft XML Parser 4.0

6. Validating XML-parser using XML Schema?

7. Anyone using CL-XML(a xml parser)?

8. CLASSes and QUEUEs (was: Re: QUEUE in QUEUE)

9. Inter process communication using Tk/send hangs on suspended processes

10. Q: Multiple processes writing to a single process using Expect

11. Processing a queue

12. Queue Processing

 

 
Powered by phpBB® Forum Software