Pages: 1
Print
Author Topic: Insert Table Button XSD  (Read 5496 times)
Abalysa
Member

Posts: 3


« on: November 26, 2013, 07:45:26 AM »

Hello,

First of all, I am a Student who just recently started to work with XMetaL.
My knowledge of XML,DITA,XML Schema etc. is kind of limited since i just started studying a few months ago.

I am using XMetaL Author 7.0 and XMetaL Developer.
I use MS Visual Studio 2012 to view and change the Source Code of the XSD file

For my current Project i am trying to make some "standart" Functions avaible on XMetaL work with our custom XSD.
But i just cant figure out how some Tags care connected with the Buttons avaible on XMetaL (the Standart list buttons in the Formatting Toolbar and the Insert Table Button)

My main Problem is that i am allowed to expand our XSD File, but not to change it in its Structure. And as far as i know the Structure is pretty bad/messy.

If someone could explain to me how i can define the Tags needed for a Table and how to connect them to the "Insert Table" Button i would be really thankful.

I hope this is understandable, if not I apologize and try to provide every Information necessary.

Kind regards
Abalysa
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: November 27, 2013, 01:46:52 PM »

Unlike other types of elements where you can specify a "treat as" type (images, lists, paragraphs) for an element with any name there is no equivalent setting for "treat as table".

However, the functionality for inserting tables is enabled automatically when XMetaL Author recognizes that your schema defines either an HTML or CALS table, with no further work to be done. This also means that this functionality cannot be hooked up to an arbitrary table type that is not one of those two.

What is recognized as HTML or CALS is flexible to some degree but works best when one of those standards is followed closely.

At minimum, your schema needs to define the following elements for XMetaL Author to support HTML tables:
table, tr, td

When elements or attributes (such as th or @width) are not defined the software attempts to compensate by disabling portions of the Table Properties dialog so the use can still edit the table. If for example, @width is not allowed, then the software will not allow the user to drag a table's borders to change its size (because there is no way to record it in the appropriate attribute) and the "cell width" and "column width" settings in the Table Properties dialog will be disabled.

At minimum, your schema needs to define the following elements for XMetaL Author to support CALS tables:
table, row, entry

For other sets of elements you wish to display as a table it is possible to build a custom "insert table" form (XFT) but it would need to build the table and insert it (there are various APIs that will let you do that but you can't use either of InsertTable or InsertCALSTable). Also, none of the standard table manipulation functions (both those in the UI and APIs) can be used on such a table after it has been inserted. This means that in order to allow someone to delete a row, move a row, move a column (and other things for which there are dedicated table manipulation APIs) you would need to duplicate those and the scripts for doing that will be difficult to write, and in some cases some of the built-in functionality for CALS and HTML tables will be impossible to reproduce.

To display a set of elements as a table (something that is not HTML or CALS) you must also use the CSS display property. It only supports "table", "table-row" and "table-cell" and also affects display only (setting these does not enable any editing functionality).

Long term we are considering adding a "treat as table" feature so that arbitrary groups of elements can gain support for display as a table and basic table manipulation functionality through configuration (possibly like the other CTM "treat-as" settings). However, as most schema use HTML or CALS this has so far been a low priority.
Logged
Abalysa
Member

Posts: 3


« Reply #2 on: November 28, 2013, 06:58:32 AM »

Hi Derek,

Thank you very much for your fast and detailed Answer.
I will try it out next week and see if i can get it work.

If you dont mind i would like to ask another, different Question here.

Is there any difference in how XFT Button Functions are handled between "Tags On View" and "Normal View" ?

I made 2 Buttons (1 XFT), one which should should add a new Review Log Step after the last Review Log Step, and one which deletes the Last Review Log Step.

I had major Problems with writing the delete Function, because apparently the last "ReviewLogEntry" Element and all his containing Elements cant be simply deleted by Range.Delete();

So i tried to Select the whole thing and then delete it. And it works. But someohow it only works in "Tag On View" in "Normal View" it just selects one of the Elements inside of the "ReviewLogEntry" Element and then does nothing.

Some Problem with adding a new "ReviewLogEntry"... again i used Selection, and again it only works in "Tag On View" and simply does nothing in "Normal View"

Whats the Difference between the Views? Why does it work in one but not in the other?

The Functions i wrote are:
ADD:
   Selection.MoveUp(0);
   Selection.SelectElement();
   Selection.Collapse(0);
   Selection.InsertWithTemplate("ReviewLogEntry");

DELETE:
       Selection.MoveUp(0);
       Selection.SelectElement();
       Selection.Delete();

Note that i dont have any experience with Jscript at all ... i worte this with help of the Programmers Guide

I know this is again a bit messy, and propably hard to understand, but if needed i can also post some Screenshots.

Thank you for your time

Kind regards,
Abalysa
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #3 on: November 28, 2013, 03:57:40 PM »

This new question is really about how the APIs function (and not where they are called from) I think, and more specifically, the way selections work in the two different views.

What an author can do in Normal view is more restricted (or more "guided") than Tags On view. The Selection object mimics this and will function equally differently in these two views. You will have more success in your particular case if you use the Range object instead. It is allowed to do more than an author (and the Selection object) can do. It is invisible and can move to some locations that an author is guided away from in Normal view. The Selection object is useful for some cases (where you want to mimic the difference) but if you want your code to function the same in both views, and you want to use the APIs you are using, then it is probably best to use Range instead.

For even more power (in some cases) you may also wish to look into using the DOM APIs.
« Last Edit: November 28, 2013, 03:59:52 PM by Derek Read » Logged
Abalysa
Member

Posts: 3


« Reply #4 on: December 05, 2013, 03:04:26 AM »

Thank you again for your Answer!

I finally got the Buttons to do exactly what i want them to do, using the DOM API as you suggested.

But now im back to my Table problem.I still cant get it to work even tough i implemented the required Tags for an HTML Table (table,tr,td) and even created a few more like tbody, thead, tfoot.

Are there any specific things i have to define in my XSD? I looked into the Journalist.xsd to get a bit of an Idea how it could work, but the journalist.xsd has a completley different structure then my own xsd... also there are a whole bunch of attributes defined in the journalist.xsd and nearly every object of the table is reffering to either a attribute group or even to another element.

This is somewhat confusing and probably I dont have the Knowledge to understand the structure of this kind of XSD and how the things interact with each other yet. But is this all needed to get the Insert Table to work?

i understand that i probably could write a macro or use an XFT form to creat a Table... but as far as i know it wouldnt be nearly as customizable as it is in the Journalist Template (Press Insert Table --> get Menu where you can choose how many rows/cells etc.).

What i want is that if you select a Paragraph Element (In my case it is named Paragraph and is set as para element in the ctm file) the Button in the Toolbar to insert a Table becomes active and if you click it you get into a menu where you can chosse how many Rows you want, how many Cells each Row has, and if you want to use a header / footer for your table.

I use VS 2012 to work with xsd and write my changes directly into the Code.
For my Template itself i have a VS 2012 Solution, with all the Forms, CSS, and the ctm file in it.

If needed i can provide a snippet or screenshot of my xsd file

I hope you got a bit of an Insight of what i want to achieve and what my Problem is

Thanks alot for your help so far :)

Kind regards,
Abalysa
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #5 on: December 05, 2013, 07:18:41 PM »

Here's a basic sample Schema that defines a set of elements that will be recognized automatically as an HTML table. It defines more than is necessary to provide basic HTML table editing capabilities.

The Insert Table options (menu and toolbar) will be enabled when the insertion point is inside a document containing a <docroot> element. The Table Properities dialog (accessed via the Table menu and context menu) will be enabled as well. Some properties will be disabled in the Table Properties dialog because corresponding attributes are not defined for them.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="docroot">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name ="p" type="xs:string" />
        <xs:element minOccurs="0" maxOccurs="unbounded" name ="table">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="caption" type="xs:string" />
              <xs:element name="thead">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="tr">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="td" type="xs:string" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="tfoot">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="tr">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="td" type="xs:string" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="tbody">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="tr">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="td" type="xs:string" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="width" type="xs:string" use="required" />
            <xs:attribute name="border" type="xs:unsignedByte" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>


With this in place (or a schema that defines similar elements: table, tr, td) you do not need to use DOM methods. You can simply call the API InsertTable() with the appropriate parameters. However, that is only if you need to script the insertion of the table for some reason. The Insert Table button or menu item will suffice for most users.
« Last Edit: December 05, 2013, 07:22:57 PM by Derek Read » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #6 on: December 05, 2013, 07:26:08 PM »

Here is the simplest possible sample I can think of that will be automatically recognized as defining an HTML table.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="docroot">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name ="p" type="xs:string" />
        <xs:element minOccurs="0" maxOccurs="unbounded" name ="table">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="tr">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="td" type="xs:string" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="width" type="xs:string" use="required" />
      <xs:attribute name="border" type="xs:unsignedByte" use="required" />
    </xs:complexType>
  </xs:element>
</xs:schema>
Logged
Pages: 1
Print
Jump to: