Anita Fohrenkamm wrote:
> 
> I have the following schema (extract):
> ...
> <xs:element name="para" type="paraType"/>
> ...
> <xs:complexType name="paraType" mixed="true">
>    <xs:sequence minOccurs="0" maxOccurs="unbounded">
>        <xs:choice>
>            <xs:element name="b" type="xs:string"/>    <!-- for bold text
> -->
>            <xs:element name="i" type="xs:string"/>     <!-- for italic
> text -->
>            <xs:element name="phrase" type="phraseType"/>
>            <xs:element name="externalLink">
>                <xs:complexType>
>                    <xs:simpleContent>
>                        <xs:extension base="xs:string">
>                            <xs:attribute name="destination"
> type="xs:string" use="required"/>
>                        </xs:extension>
>                    </xs:simpleContent>
>                </xs:complexType>
>            </xs:element>
>            <xs:element name="sub" type="xs:string"/>   <!-- for
> subscript -->
>            <xs:element name="super" type="xs:string"/> <!-- for
> superscript -->
>        </xs:choice>
>    </xs:sequence>
>    <xs:attribute name="onlyProject" type="onlyProjectType" use="optional"/>
> </xs:complexType>
> .....
> 
> I have inserted following menu items to an toolbar button for converting
> text selections and nodes:
> 
> <menu>
>   <item label="Convert to plain text"
>            command="convert"
>            parameter="[implicitElement] #text"/>
>   <item label="Convert to bold"
>            command="convert"
>            parameter="[implicitElement] b"/>   <item label="Convert to
> italic"
>            command="convert"
>            parameter="[implicitElement] i"/>
>    <item label="Convert to subscript"
>            command="convert"
>            parameter="[implicitElement] sub"/>
> </menu>
> 
> "Convert to plain text" works fine if  I try to convert an inserted
> bold, italic or other node to plain text.
> The other convert commands do not work. What is wrong?

[1] By using type "xs:string" for element "b":

<xs:element name="b" type="xs:string"/>

you are saying to XXE that element "b" contains *data* (which could be
for example constrained to match a regular expression!) and not *text*.
This prevents "b" from being a possible target for the "convert" operation.

You need to use this kind of type for b, u, etc:

<xs:complexType name="plainTextType" mixed="true" />



[2] If you use a namespace for your elements, you cannot simply
reference "b", "i", "sub", etc, in the parameter of the convert command.

Let's suppose the URI of the namespace is
"http://www.alcatel.de/namespace/doc";.

---
<item label="Convert to bold"
  command="convert"
  parameter="[implicitElement] b"/>
---

must be replaced by:

---
<item label="Convert to bold"
  command="convert"
 parameter="[implicitElement] {http://www.alcatel.de/namespace/doc}b"/>
---

Note that commmand parameters contains plain strings without special
semantics and therefore, namespace prefixes are not interpreted in this
context.


Reply via email to