Thanks, Hussein.

Susan

-----Original Message-----
From: Hussein Shafie [mailto:[email protected]] 
Sent: Friday, January 06, 2012 12:11 PM
To: Harris, Susan
Cc: '[email protected]'
Subject: Re: [XXE] Making tagged elements or nodes Read-Only when two 
namespaces are present

--> This part of the documentation is especially not well-written. We'll 
improve it in the next release.

---
Note that selectNode.ancestor* selects all the ancestors one after the 
other until it reaches the found ancestor.

This is equivalent to interactively typing Ctrl+Up until the desired 
ancestor is selected.

The idea behind that is to be able to use selectNode ancestor followed 
by selectNode child or selectNode descendant* in the same macro-command.
---

should read:

---
Note that selectNode ancestor one_or_more_element_names selects all the 
ancestors one after the other until it reaches the found ancestor.

This is equivalent to interactively typing Ctrl+Up until the desired 
ancestor is selected.

The idea behind that is to be able to use 
selectNode ancestor one_or_more_element_names followed by 
selectNode child or selectNode descendant one_or_more_element_names in 
the same macro-command.
---

Therefore, you cannot specify an '*' anywhere in the parameter of 
command selectNode.




--> "self[implicitNode] true" is an incorrect parameter for setReadOnly. 
You should specify "[implicitNode] true". See 
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/setReadOnly.html




--> command selectNode is not well-adapted to what you want to do. This 
command has been designed mainly to be used interactively.

command setReadOnly has a lot of limitations, for example, it cannot 
mark multiple sibling nodes at the same time. We mainly use setReadOnly 
for testing the behavior of the UI when part or all of a document 
switches from read-only state to editable state and the opposite way round.

In your case, a single, rather simple, command written in Java (or even 
better a document hook written in Java) would be a much better choice.




--> I am not sure to understand the structure of your documents 
therefore it's difficult for me tell you what to do (apart fixing the 
"*" next to "descendant[implicitNode]" and the incorrect parameter of 
setReadOnly).

However, I would strongly recommend to rewrite your macros as follows:

---
<command name="readOnlyNamedEntity">
   <macro>
     <sequence>
       <set variable="selectedElement"
            context="$implicitNode/ancestor-or-self::clml:resource"
            expression="./clml:content//clg:named-entity" />

       <command name="setReadOnly" parameter="true" />
     </sequence>
   </macro>
</command>
---

Notes:

* The above <set> element reads as follows:
   (1) Start from implicitely selected node.
   (2) Find its clml:resource ancestor.
   (3) If there is one, find all the clg:named-entity descendants of its 
clml:content children.
   (4) The first clg:named-entity in document order becomes the selected 
element.

See http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpath_vars.html

* Unlike selectNode, the <set> element is namespace-aware, therefore 
declaring:

---
xmlns:clml="http://www.xml.cengage.learning-marklogic.com/marklogic";
xmlns:clg="http://www.xml.cengage-learning-gale.com/docbook-core";
---

is *really* needed.

* The above technique should work fine even in old releases of XXE (v4.x).





On 01/06/2012 03:52 PM, Harris, Susan wrote:
> We are working with two namespaces in our XML files that the XML Mind
> Editor file loads. We are able to make elements read-only that are in
> the root namespace, for both examples below:
> <binding>
> <keyPressedcode="F6"/>
> <commandname="readOnlyMetadata"/>
> </binding>
> <commandname="readOnlyMetadata">
> <macroundoable="true">
> <sequence>
> <commandname="selectNode"parameter="ancestorOrSelf[implicitNode]
> {http://www.xml.cengage.learning-marklogic.com/marklogic}resource"/>
> <commandname="selectNode"parameter="child[implicitNode]
> {http://www.xml.cengage.learning-marklogic.com/marklogic}metadata"/>
> <commandname="setReadOnly"parameter="self[implicitNode] true"/>
> </sequence>
> </macro>
> </command>
> <binding>
> <keyPressedcode="F8"/>
> <commandname="readOnlyNamedEntity"/>
> </binding>
> <commandname="readOnlyNamedEntity">
> <macroundoable="true">
> <sequence>
> <commandname="selectNode"parameter="ancestorOrSelf[implicitNode]
> {http://www.xml.cengage.learning-marklogic.com/marklogic}resource"/>
> <commandname="selectNode"parameter="child[implicitNode]
> {http://www.xml.cengage.learning-marklogic.com/marklogic}content"/>
> <commandname="setReadOnly"parameter="self[implicitNode] true"/>
> </sequence>
> </macro>
> </command>
> However, when trying to make a subset of tags read-only that reside in
> the second namespace, under the content tag, read-only does not work, as
> coded below:
> <binding>
> <keyPressedcode="F8"/>
> <commandname="readOnlyNamedEntity"/>
> </binding>
> <commandname="readOnlyNamedEntity">
> <macroundoable="true">
> <sequence>
> <commandname="selectNode"parameter="ancestorOrSelf[implicitNode]
> {http://www.xml.cengage.learning-marklogic.com/marklogic}resource"/>
> <commandname="selectNode"parameter="child[implicitNode]
> {http://www.xml.cengage.learning-marklogic.com/marklogic}content"/>
> <commandname="selectNode"parameter="descendant[implicitNode]*
> {http://www.xml.cengage-learning-gale.com/docbook-core}named-entity"/>
> <commandname="setReadOnly"parameter="self[implicitNode] true"/>
> </sequence>
> </macro>
> </command>
> When F8 is hit, only the first command, which selects the root, is
> highlighted in the editor.
> Both namespaces are defined on the root config element:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <configurationxmlns="http://www.xmlmind.com/xmleditor/schema/configuration"xmlns:cfg="http://www.xmlmind.com/xmleditor/schema/configuration"xmlns:clml="http://www.xml.cengage.learning-marklogic.com/marklogic":clg="http://www.xml.cengage-learning-gale.com/docbook-core";>
> How can we get the highlighted named-entity descendant elements
> read-only, too (all of these descendant elements in the tree structure),
> while keeping all the other clg: elements editable in the editor?
> ---------------
> Also, what is the difference between selectNode.ancestor* and selectNode
> ancestor*?
> Can it apply to selectNode.descendant* and selectNode descendant*?
 
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to