Pages: 1
Print
Author Topic: ToggleInline  (Read 1091 times)
chrisb
Member

Posts: 1


« on: July 02, 2010, 08:29:22 AM »

I'm using XMAX v6.0 and am trying to use the ToggleInline function on the Selection object of the control.  I cannot get the function to work and am receiving no feedback from the control.

Example code: xmaxControl.Selection.ToggleInline("B")

I have also tried with the ToggleInlineNS and the appropriate namespaces.  I've cut back the schema and file to be as simple as possible and still nothing.

Any help would be much appreciated.

Chris

This is the xml file:

<?xml version="1.0" encoding="utf-8"?>
<paper xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://www.tempuri.org/paper ./schema.xsd"
               xmlns="http://www.tempuri.org/paper">
  <body>
    <section>
      <paragraph>
        Loremb ipsum dolor sit amet, consectetur adipiscing elit. Nullam lacus dolor, pretium vel semper non, porttitor ac elit. Quisque non urna ante, a dictum mauris. Phasellus non mauris purus, eget egestas erat. Integer tristique lacus nec mi posuere venenatis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam nunc libero, fermentum vitae aliquet a, lobortis non sem. Duis et justo sit amet tellus facilisis cursus in laoreet magna. Nulla euismod mollis faucibus. Phasellus luctus blandit orci, id pellentesque diam posuere a. Praesent cursus purus vitae dolor pretium sodales. Donec dictum egestas nulla ut faucibus. Nunc at diam sit amet urna adipiscing tincidunt. Praesent commodo augue eget neque condimentum ultrices vitae eget nulla. Nulla facilisi. Phasellus convallis consectetur nulla, a commodo purus commodo ut.
      </paragraph>
    </section>
  </body>

</paper>

and this is the schema:

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema
  targetNamespace="http://www.tempuri.org/paper"
  elementFormDefault="qualified"
  xmlns="http://www.tempuri.org/paper"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <xsd:element name="paper">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="body" type="paper.Body" minOccurs="1" maxOccurs="1"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:complexType name="paper.Body">   
    <xsd:sequence>
      <xsd:element name="section" minOccurs="0" maxOccurs="unbounded">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="paragraph" minOccurs="0" maxOccurs="unbounded">
              <xsd:complexType mixed="true">
                <xsd:choice minOccurs="0" maxOccurs="unbounded">
                  <xsd:element name="emphasis" type="xsd:string" />
                  <xsd:element name="strong" type="xsd:string" />
                  <xsd:element name="underline" type="xsd:string" />
                  <xsd:element name="superscript" type="xsd:string" />
                  <xsd:element name="subscript" type="xsd:string" />
                  <xsd:element name="B" type="xsd:string" />
                  <xsd:element name="I" type="xsd:string" />
                </xsd:choice>
              </xsd:complexType>
            </xsd:element>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

</xsd:schema>




Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1552



WWW
« Reply #1 on: July 02, 2010, 12:58:01 PM »

Unfortunately, it looks like this is a known issue that has yet to be addressed, or at least there is another issue that looks like this one. I'm not sure exactly what the exact issue is here because other Schemas and instances I have tried are OK. Development will be looking into it though.

In my testing the following are working:
Selection.Surround("B")
Selection.SurroundNS("http://www.tempuri.org/paper","B")
Selection.RemoveContainerTags()

So, all is not lost. I believe adding a little bit of logic together with those APIs makes it possible to obtain the same results. Something like this:

'XMetaL Script Language VBScript:
SET rng = ActiveDocument.Range
if (rng.ContainerName = "B") then
   rng.RemoveContainerTags()
else
   rng.Surround("B")
   rng.Select()
end if


(written in VBScript as it looks like you are either working with VB or VBScript, just a guess)
« Last Edit: July 02, 2010, 03:36:41 PM by Derek Read » Logged
steves
Member

Posts: 1


« Reply #2 on: July 09, 2010, 12:53:54 AM »

The problem is with the schema itself. The paragraph element contains strong, emphasis and underline elements inline e.g.

<xsd:element name="emphasis" type="xsd:string" />
<xsd:element name="strong" type="xsd:string" />
<xsd:element name="underline" type="xsd:string" />

(same with the super/subscript).

What you need to do is create a type for the above as follows...

<xsd:element name="strong" type="StrongType"/>

...etc

and then define the type...

<xsd:complexType name="StrongType" mixed="true">
  <xsd:choice maxOccurs="unbounded">
    <xsd:element ref="emphasis" minOccurs="0" maxOccurs="unbounded"/>
  </xsd:choice>
</xsd:complexType>

Note that the emphasis is included (as well may the underline) to allow strong/emphasis combinations.

Now you need to include the elements defined using the ref attribute instead...

<xsd:element ref="strong" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="emphasis" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="underline" minOccurs="0" maxOccurs="unbounded"/>

The modified schema is thus:

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema
  targetNamespace="http://www.tempuri.org/paper"
  elementFormDefault="qualified"
  xmlns="http://www.tempuri.org/paper"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <xsd:element name="paper">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="body" type="paper.Body" minOccurs="1" maxOccurs="1"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="strong" type="StrongType"/>
  <xsd:element name="emphasis" type="EmphasisType"/>
  <xsd:element name="underline" type="UnderlineType"/>

  <xsd:complexType name="StrongType" mixed="true">
    <xsd:choice maxOccurs="unbounded">
      <xsd:element ref="emphasis" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element ref="underline" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:choice>
  </xsd:complexType>

  <xsd:complexType name="EmphasisType" mixed="true">
    <xsd:choice maxOccurs="unbounded">
      <xsd:element ref="strong" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element ref="underline" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:choice>
  </xsd:complexType>

  <xsd:complexType name="UnderlineType" mixed="true">
    <xsd:choice maxOccurs="unbounded">
      <xsd:element ref="strong" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element ref="emphasis" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:choice>
  </xsd:complexType>

  <xsd:complexType name="paper.Body">   
    <xsd:sequence>
      <xsd:element name="section" minOccurs="0" maxOccurs="unbounded">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="paragraph" minOccurs="0" maxOccurs="unbounded">
              <xsd:complexType mixed="true">
                <xsd:choice minOccurs="0" maxOccurs="unbounded">
                  <xsd:element ref="emphasis" minOccurs="0" maxOccurs="unbounded" />
                  <xsd:element ref="strong" minOccurs="0" maxOccurs="unbounded" />
                  <xsd:element ref="underline" minOccurs="0" maxOccurs="unbounded" />
                  <xsd:element name="superscript" type="xsd:string" />
                  <xsd:element name="subscript" type="xsd:string" />
                  <xsd:element name="B" type="xsd:string" />
                  <xsd:element name="I" type="xsd:string" />
                </xsd:choice>
              </xsd:complexType>
            </xsd:element>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

</xsd:schema>

Even though the previous schema was perfectly valid and the xmax tool itself validates it, I do not know why it does not work in the previous form. This does however work and I have tried it in a sample .net application (which is attached).

Regards
SteveS

* XMaxSchemaDemo.zip (200.82 KB - downloaded 69 times.)
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1552



WWW
« Reply #3 on: July 09, 2010, 11:35:41 AM »

Thank you for finding this. I'll include this updated info with my report to development.
Logged
Pages: 1
Print
Jump to: