Thomas Dumm wrote:
> 
> Do you know the right 2 command lines to set a variable and afterwards
> use the variable in the following macro which should open a cross
> referenced document (attribute srcfile) and navigate to the Element
> containing the id (attribute Id)? I marked the two lines that need to be
> finished in red.
> 
> The manual about the variables does not lead me to the right answer.
>  
> <command name="gre.editPage">
> <macro>
> <sequence>
> <test expression="$implicitElement/@Idref"/>
> <choice>
> <sequence>
> <test expression="$implicitElement/@srcfile"/>
> <get context="$implicitElement/@srcfile" expression="resolve-uri(.)"/>
> 
> *< set ...?/>*
> 
> *
> *<command name="XXE.edit" parameter="%_"/>
> 
> <command name="selectById" *parameter**="...???"/>*
> 
> </sequence>
> <sequence>
> <command name="selectById" parameter="id"/>
> </sequence>
> </choice>
> </sequence>
> </macro>
> </command>
> 

[1] This should work fine:
---
<get context="$implicitElement/@srcfile" expression="resolve-uri(.)"/>
<command name="XXE.edit" parameter="%_"/>
---
because the <get> element returns a value and because the last returned
value is always available in the "%_" variable.


[2] Now let's make the problem more complicated by adding the ID found
in $implicitElement/@Idref.

This *could* have worked:

---
<set variable="theId" expression="$implicitElement/@Idref"/>

<get context="$implicitElement/@srcfile" expression="resolve-uri(.)"/>
<command name="XXE.edit" parameter="%_"/>

<get expression="$theId" />
<command name="selectById" parameter="id %_" />
---

However, it will *not* work because a command cannot switch its context
from a document to another document.

--> Explanations:

The command is executed in the context of doc1.xml. doc1.xml references
doc2.xml#foo. We want to open doc2.xml and then jump to the element
contained in doc2.xml having "foo" as its ID.

---
<!-- we are in doc1.xml -->
<set variable="theId" expression="$implicitElement/@Idref"/>
<!-- theId now contains "foo" -->

<get context="$implicitElement/@srcfile" expression="resolve-uri(.)"/>
<command name="XXE.edit" parameter="%_"/>
<!--XXE has opened doc2.xml in another window
    but the macro still works on doc1.xml-->

<get expression="$theId" />
<command name="selectById" parameter="id %_" />
<!-- Fails: doc1.xml contains no element having "foo" as its ID-->
---





Reply via email to