# Starting points for learning how to script a customized report

**URL:** <https://forums.toadworld.com/t/starting-points-for-learning-how-to-script-a-customized-report/2061>\
**Category:** Toad Data Modeler\
**Created:** [September 3, 2009, 8:19am UTC](https://forums.toadworld.com/t/starting-points-for-learning-how-to-script-a-customized-report/2061 "2009-09-03T08:19:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndreasL](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@AndreasL](https://forums.toadworld.com/u/AndreasL)\
**Post date:** [September 3, 2009, 8:19am UTC](https://forums.toadworld.com/t/starting-points-for-learning-how-to-script-a-customized-report/2061/1 "2009-09-03T08:19:43Z")

</div>

Similar as I can generate a DDL script or HTML report out of box, I’d like to have a script that generates a indiviual XML representation for all tables and columns of my model.

I’d need to iterate over each table and each column, having access to table/column name and datatype.

Would you use the report or the scriptng engine?

Where are good starting points to learn how to write such a script?  
Where can I find example scripts that cover similar issues?

Thanx a lot.  
Andreas

---

<div class="post-metadata">

**Author:** ![Vaclav\_Frolik](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/vaclav_frolik/32/12_2.png) [@Vaclav\_Frolik](https://forums.toadworld.com/u/Vaclav_Frolik)\
**Post date:** [September 3, 2009, 8:32am UTC](https://forums.toadworld.com/t/starting-points-for-learning-how-to-script-a-customized-report/2061/2 "2009-09-03T08:32:14Z")

</div>

Hi,

you can use internal scripting or you can take advantage of the XSL tranformation. The second option might be better. Have a look at the User Guide (Help | User Guide), section Physical Modeling -\> Documentation -\> XSL Transformation.

I published two articles about XSL transformation. You can find them at:  
[http://blogs.inside.quest.com/modeling/2009/02/09/xslt-reports-part-1/](http://blogs.inside.quest.com/modeling/2009/02/09/xslt-reports-part-1/)  
[http://blogs.inside.quest.com/modeling/2009/02/17/xslt-reports-part-2/](http://blogs.inside.quest.com/modeling/2009/02/17/xslt-reports-part-2/)

If the XSL transformation is not what you need, please download scripts from the following location. You will find there information how to iterate entities and other objects:

[http://modeling.inside.quest.com/kbcategory.jspa?categoryID=35](http://modeling.inside.quest.com/kbcategory.jspa?categoryID=35)

Regards,

Vaclav

---

<div class="post-metadata">

**Author:** ![AndreasL](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@AndreasL](https://forums.toadworld.com/u/AndreasL)\
**Post date:** [September 3, 2009, 12:22pm UTC](https://forums.toadworld.com/t/starting-points-for-learning-how-to-script-a-customized-report/2061/3 "2009-09-03T12:22:17Z")

</div>

Thanx, I’ll check out these templates.

---

<div class="post-metadata">

**Author:** ![AndreasL](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@AndreasL](https://forums.toadworld.com/u/AndreasL)\
**Post date:** [September 3, 2009, 1:16pm UTC](https://forums.toadworld.com/t/starting-points-for-learning-how-to-script-a-customized-report/2061/4 "2009-09-03T13:16:31Z")

</div>

I prefer JScript scripting.  
Iterating over all entities and attributes seems easy.  
But how to generate the output?  
With Log.Information my code goes to the log, that can be exported, but with date and time prefix. Not very comfortable…  
I’d prefer to open a window with a textbox where I could copy’n’paste the result.  
How could this be achieved?

I found the scripts for DDL generation, there DDLScript.WriteLine is used. Is this the right way to go?

Is there an easy way to just open a file and write my output to this file?

I cannot find any documentation for scripting that answers such questions?!  
Where can I find a documentation about available predefined objects and obejcts like System, Application, Log e.g.?

Thanx a lot  
Andreas

---

<div class="post-metadata">

**Author:** ![DavidF](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@DavidF](https://forums.toadworld.com/u/DavidF)\
**Post date:** [September 4, 2009, 3:53am UTC](https://forums.toadworld.com/t/starting-points-for-learning-how-to-script-a-customized-report/2061/5 "2009-09-04T03:53:39Z")

</div>

Hi Andreas,

Yes, there is a very easy way how to create a new text stream to write content into it and save it. You can create instead of a text file also a XML document easily. Below is a simple script that creates one text file and one xml file and fills it with a list of entities.

function main()  
{  
var app = System.GetInterface(‘Application’);

- 

```
    //... parameter in GetObject determines with which model the script should work.
   //0 = first model listed in the Application View, 1 = second model listed in the Application View etc.*

   var Model = app.Models.GetObject(0);

```

_// sample #1: writing entity names into a UTF text file  
// create a text stream_

```
     var TextStream = System.CreateObject( "TextStream" );
     TextStream.FileName = "C:\\TestTextOutput.txt";
     for (e=0; e<Model.Entities.Count; e++)
     {
         Entity = Model.Entities.GetObject( e );
         TextStream.WriteLine( Entity.Name );
     }   
     TextStream.SaveToFile();

```

- 

```
    // sample #2: writing entity names into a XML file
   // create a DOM object*

   var xmlDoc = new ActiveXObject( "Msxml2.DOMDocument.3.0" );   
   var EntNodes = xmlDoc.createElement( 'Entities' );
   var EntNode;
  
   for (e=0; e<Model.Entities.Count; e++)
   {
       Entity = Model.Entities.GetObject( e );
       EntNode = xmlDoc.createElement( "Entity" );
       
       EntNode.text = Entity.Name;
      
       EntNodes.appendChild( EntNode );
   }   
   xmlDoc.appendChild( EntNodes );
   xmlDoc.save( "C:\\TestXMLOutput.xml" );

```

}

I think this script is very easy to understand, but if you should have any questions don’t hesitate to ask.

David

Message was edited by: DavidF

---

<div class="post-metadata">

**Author:** ![AndreasL](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@AndreasL](https://forums.toadworld.com/u/AndreasL)\
**Post date:** [September 4, 2009, 4:02am UTC](https://forums.toadworld.com/t/starting-points-for-learning-how-to-script-a-customized-report/2061/6 "2009-09-04T04:02:11Z")

</div>

Perfect! Thanx a lot.  
This support forum is so fantastic and it’s a great product!  
Way to go!

Andreas
