Loading ...
Sorry, an error occurred while loading the content.
 

Re: [XSL-FO] xml tree representation

Expand Messages
  • G. Ken Holman
    ... To use XSLT to emit the plain text file representing the nodes, we have a free resource called SHOWTREE (follow the Resource library link at the top of
    Message 1 of 4 , Mar 1, 2002
      At 2002-03-01 08:10 -0800, Paul Tyson wrote:
      >In either case, you could use XSLT to emit a plain text file representing
      >the nodes and their relationships, then call the graph layout program to
      >produce a graphic file.
      >
      >--Paul
      >
      >----- Original Message -----
      >From: "Anders Svensson" <asn@...>
      >To: <XSL-FO@yahoogroups.com>
      >Sent: Friday, March 01, 2002 7:18 AM
      >Subject: [XSL-FO] xml tree representation
      >
      >
      > > Hi,
      > >
      > > I'm looking for a way to create a graph/tree representation of an xml
      > document,

      To use XSLT to emit the plain text file representing the nodes, we have a
      free resource called SHOWTREE (follow the "Resource library" link at the
      top of our home page noted below; it is the third entry in the library).

      I hope this helps.

      ............. Ken

      X:\samp>type partlist.xml
      <?xml version="1.0"?>
      <!--start-->
      <part-list bin="78"><part nbr="A123">bolt</part>
      <part nbr="B456">washer</part><warn type="refill"/>
      <!--end of parts--><?cursor blink under?>
      </part-list>

      X:\samp>saxon partlist.xml z:\data\kendata\dev\showtree\showtree.xsl
      SHOWTREE Stylesheet
      Processor: SAXON 6.5 from Michael Kay
      1 Comment: {start}
      2 Element 'part-list':
      2.A Attribute 'bin': {78}
      2.1 Element 'part' (part-list):
      2.1.A Attribute 'nbr': {A123}
      2.1.1 Text (part-list,part): {bolt}
      2.2 Text (part-list): {
      }
      2.3 Element 'part' (part-list):
      2.3.A Attribute 'nbr': {B456}
      2.3.1 Text (part-list,part): {washer}
      2.4 Element 'warn' (part-list):
      2.4.A Attribute 'type': {refill}
      2.5 Text (part-list): {
      }
      2.6 Comment (part-list): {end of parts}
      2.7 Proc. Inst. 'cursor' (part-list): {blink under}
      2.8 Text (part-list): {
      }
      X:\samp>


      --
      Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO: June 17-21, 2002
      - : 3-days XML Information Modeling: July 31-August 2, 2002

      G. Ken Holman mailto:gkholman@...
      Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
      Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
      ISBN 0-13-065196-6 Definitive XSLT & XPath
      ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
      ISBN 1-894049-07-1 Practical Formatting Using XSLFO
      XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed),
      articles, training(instructor-live,Internet-live,web/CD,licensed)
      Next public training: 2002-03-01,04,05,06,11,15,04-08,09,10,11,
      - 05-06,07,09,10,20,06-04,07,10,11,13,14,17,20,07-31
    • Anders Svensson
      Maybe someone would be able to figure this problem out if they saw the source code (very simple experimenting code) from VB. This takes the XML input and tries
      Message 2 of 4 , Mar 1, 2002
        Maybe someone would be able to figure this problem out if they saw the source code (very simple experimenting code) from VB. This takes the XML input and tries to plot the elements out in the picture box. If I had gotten this right I had planned to go on to drawing lines in the tree, but I never got that far.. As it is, it plots elements out, but incorrectly. Here goes - any help appreciated as always:


        Sub DrawTree()

        LoadXML

        End Sub

        Function Draw(node)
        Dim xPos
        Dim yPos
        xPos = 130
        yPos = 20
        frmDrawTree.Picture1.Print node
        ' frmDrawTree.Picture1.Line (xPos + 2, yPos + 15)-(xPos - 10, yPos + 50), RGB(0, 0, 0)
        End Function

        Sub LoadXML()

        Dim xmlDoc As MSXML2.DOMDocument
        Set xmlDoc = New MSXML2.DOMDocument
        xmlDoc.LoadXML ("<customer><first_name>Joe</first_name><last_name>Smith</last_name></customer>")
        Call tree_walk(xmlDoc, 160, 20)
        End Sub

        Function WalkTree(node)
        Dim xnode As MSXML2.DOMDocument
        Set xnode = node

        If xnode.hasChildNodes Then
        For Each child In xnode.childNodes
        Call Draw(xnode.firstChild)
        Next

        End Function

        Function tree_walk(node, prevNodeSpace, ySpace)

        Dim nodeName
        Dim child
        Dim i
        Dim spaceVar
        Dim tempNodeSpace


        tempNodeSpace = prevNodeSpace


        For Each child In node.childNodes
        frmDrawTree.Picture1.CurrentX = prevNodeSpace
        frmDrawTree.Picture1.CurrentY = ySpace
        Call Draw(node.childNodes(i).nodeName)

        prevNodeSpace = prevNodeSpace * 3
        Next

        prevNodeSpace = tempNodeSpace


        For Each child In node.childNodes
        If child.hasChildNodes Then
        prevNodeSpace = prevNodeSpace / 2
        ySpace = ySpace + 20
        prevNodeSpace = prevNodeSpace
        Call tree_walk(child, prevNodeSpace, ySpace)

        End If
        Next

        End Function


        Best,

        Anders


        -----Original Message-----
        From: G. Ken Holman [mailto:gkholman@...]
        Sent: den 1 mars 2002 17:22
        To: XSL-FO@yahoogroups.com
        Subject: Re: [XSL-FO] xml tree representation


        At 2002-03-01 08:10 -0800, Paul Tyson wrote:
        >In either case, you could use XSLT to emit a plain text file representing
        >the nodes and their relationships, then call the graph layout program to
        >produce a graphic file.
        >
        >--Paul
        >
        >----- Original Message -----
        >From: "Anders Svensson" <asn@...>
        >To: <XSL-FO@yahoogroups.com>
        >Sent: Friday, March 01, 2002 7:18 AM
        >Subject: [XSL-FO] xml tree representation
        >
        >
        > > Hi,
        > >
        > > I'm looking for a way to create a graph/tree representation of an xml
        > document,

        To use XSLT to emit the plain text file representing the nodes, we have a
        free resource called SHOWTREE (follow the "Resource library" link at the
        top of our home page noted below; it is the third entry in the library).

        I hope this helps.

        ............. Ken

        X:\samp>type partlist.xml
        <?xml version="1.0"?>
        <!--start-->
        <part-list bin="78"><part nbr="A123">bolt</part>
        <part nbr="B456">washer</part><warn type="refill"/>
        <!--end of parts--><?cursor blink under?>
        </part-list>

        X:\samp>saxon partlist.xml z:\data\kendata\dev\showtree\showtree.xsl
        SHOWTREE Stylesheet
        Processor: SAXON 6.5 from Michael Kay
        1 Comment: {start}
        2 Element 'part-list':
        2.A Attribute 'bin': {78}
        2.1 Element 'part' (part-list):
        2.1.A Attribute 'nbr': {A123}
        2.1.1 Text (part-list,part): {bolt}
        2.2 Text (part-list): {
        }
        2.3 Element 'part' (part-list):
        2.3.A Attribute 'nbr': {B456}
        2.3.1 Text (part-list,part): {washer}
        2.4 Element 'warn' (part-list):
        2.4.A Attribute 'type': {refill}
        2.5 Text (part-list): {
        }
        2.6 Comment (part-list): {end of parts}
        2.7 Proc. Inst. 'cursor' (part-list): {blink under}
        2.8 Text (part-list): {
        }
        X:\samp>


        --
        Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO: June 17-21, 2002
        - : 3-days XML Information Modeling: July 31-August 2, 2002

        G. Ken Holman mailto:gkholman@...
        Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
        Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
        ISBN 0-13-065196-6 Definitive XSLT & XPath
        ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
        ISBN 1-894049-07-1 Practical Formatting Using XSLFO
        XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed),
        articles, training(instructor-live,Internet-live,web/CD,licensed)
        Next public training: 2002-03-01,04,05,06,11,15,04-08,09,10,11,
        - 05-06,07,09,10,20,06-04,07,10,11,13,14,17,20,07-31



        To unsubscribe from this group, send an email to:
        XSL-FO-unsubscribe@egroups.com



        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      Your message has been successfully submitted and would be delivered to recipients shortly.