Tyrin Avery wrote:
> Specifying filename or URL for XXE.open
> I want to add a button that lets me open a file from my ditamap. 
> So I've added the command button: 
> 
> @property-value open-file()
>          command-button(text, "OpenFile",
>                               icon, square, 
>                               command, "XXE.open",
>                               parameter, attr(href));
> 
> 
> to the appropriate styles:
> 
>     topichead:before {
>         content: paragraph(content(item-collapser(), " ",
> element-name(), " ",
>                                    " navtitle=", attr(navtitle), 
>                                    " ", 
>                                    drop-site(icon, icon(drop2),
>                                            color, gray,
>                                            command,
> "ditamap.dropTopicref",
>                                            parameter, "topicref
> '%{value}'"), " ",open-file() ));
> 
> Unfortunately, the problem I'm having is in specifying the filename. I
> want to take the value from the href attribute, which is a relative URL,
> i.e. reference/r_register_requirements.dita and use it to open that
> file. 
> If I don't put in a parameter, I get an open file box, which is the
> correct behavior. If I just put in a reference to the href attribute
> (attr(href)or , "href '%{value}'"), the command button appears but
> doesn't do anything. If I put in "file:///" "attr(href)" I get a message
> saying it can't open the file. 
> 
> What is the filename/URL supposed to look like? I couldn't find any
> examples in the doc or the samples. Can I specify this with a relative
> URL? 

[1] You should use XXE.edit rather than XXE.open. Unlike XXE.open, 
XXE.edit will simply switch to the file if it is already opened in XXE.
See http://www.xmlmind.com/xmleditor/_distrib/doc/commands/XXE.edit.html

[2] You need to pass an absolute URL to XXE.edit (or XXE.open).
In order to convert a relative URL to an absolute one, you need:

[a] to use xpath() instead of attr(). See 
http://www.xmlmind.com/xmleditor/_distrib/doc/csssupport/xpath.html

[b] to use XPath extension function
---
string resolve-uri(string uri, ?string base?)
---
See http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpathextfunc.html

I've not tested this but:
---
@property-value open-file()
          command-button(text, "OpenFile",
                                icon, square,
                                command, "XXE.open",
                                parameter, xpath("resolve-uri(@href)"));

---
should work fine.



---
PS: The DITA toolbar already has a button which does exactly what you want.

Reply via email to