document() works in Oxygen but not from command line
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 9
- Joined: Fri Nov 27, 2020 5:52 pm
document() works in Oxygen but not from command line
Hello,
Apologies if this has been asked/answered before. I did search before posting, but did not find anything that looked like it was specific to my situation.
I'm developing an XHTML plugin in Oxygen. In the plugin I am calling the document() function to pull some data I need but don't have access to in certain contexts. This works fine when I run the transformation from Oxygen, but I ultimately need to run it from the command line. Unfortunately, when I run the transformation from the command line, the document() call that works in Oxygen is returning an empty string.
My guess is that there lib(s) that Oxygen is referencing when I run the transformation that help to resolve the path to the document I need to open. I'm wondering if anyone can tell me which ones so I could attempt to include them in my command-line input. Also, if I'm totally on the wrong path and doing something that is not going to be possible, that would also be helpful to know.
Thanks in advance.
Apologies if this has been asked/answered before. I did search before posting, but did not find anything that looked like it was specific to my situation.
I'm developing an XHTML plugin in Oxygen. In the plugin I am calling the document() function to pull some data I need but don't have access to in certain contexts. This works fine when I run the transformation from Oxygen, but I ultimately need to run it from the command line. Unfortunately, when I run the transformation from the command line, the document() call that works in Oxygen is returning an empty string.
My guess is that there lib(s) that Oxygen is referencing when I run the transformation that help to resolve the path to the document I need to open. I'm wondering if anyone can tell me which ones so I could attempt to include them in my command-line input. Also, if I'm totally on the wrong path and doing something that is not going to be possible, that would also be helpful to know.
Thanks in advance.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: document() works in Oxygen but not from command line
Hi,
I'm afraid I need more details.
By "XHTML plugin" do you mean a DITA Open Toolkit plugin which customizes the XHTML output? Or do you mean something else?
How does the XSLT code which calls the document() function look like?
Could you maybe add some xsl:message's in the XSLT to see what parameter you pass to the function and if it resolves to the proper URL absolute location of the file that you want to load?
Regards,
Radu
I'm afraid I need more details.
By "XHTML plugin" do you mean a DITA Open Toolkit plugin which customizes the XHTML output? Or do you mean something else?
How does the XSLT code which calls the document() function look like?
Could you maybe add some xsl:message's in the XSLT to see what parameter you pass to the function and if it resolves to the proper URL absolute location of the file that you want to load?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9
- Joined: Fri Nov 27, 2020 5:52 pm
Re: document() works in Oxygen but not from command line
Hi Radu,
Yes, I am making a DITA OT plugin that extends the XHTML transformation.
The code which calls the document function is as follows:
<xsl:param name="input.map.url"/>
<xsl:variable name="inputMap" select="document(concat('file:/', $input.map.url), .)"/>
I believe in this case my comnmand-line argument "--input=" is available inside dita.xsl.xhtml as input.map.url. When running in Oxygen it works as I expect it to; the contents of the root ditamap are available inside $inputMap and I can gather all the information I need into another variable. However, from the command line, while $input.map.url is correct (confirmed by xsl:message), the $inputMap is empty. I tried using 'file:/', 'file://' and 'file:///' because I have had issues with this in the past, and none of them work at the command line.
The reason I am doing this is because when I am processing individual files for output, I still need access to some map-level information. Usually when working with PDF, I have access to all of this at once, but I don't know if there is a (correct) way to access map-level information when inside individual topics in HTML transformations. If there is another way to go about accessing map-level information while processing individual topics in an XHTML transformation, perhaps that could help me get around this issue altogether.
Thanks for your attention to my issue.
Yes, I am making a DITA OT plugin that extends the XHTML transformation.
The code which calls the document function is as follows:
<xsl:param name="input.map.url"/>
<xsl:variable name="inputMap" select="document(concat('file:/', $input.map.url), .)"/>
I believe in this case my comnmand-line argument "--input=" is available inside dita.xsl.xhtml as input.map.url. When running in Oxygen it works as I expect it to; the contents of the root ditamap are available inside $inputMap and I can gather all the information I need into another variable. However, from the command line, while $input.map.url is correct (confirmed by xsl:message), the $inputMap is empty. I tried using 'file:/', 'file://' and 'file:///' because I have had issues with this in the past, and none of them work at the command line.
The reason I am doing this is because when I am processing individual files for output, I still need access to some map-level information. Usually when working with PDF, I have access to all of this at once, but I don't know if there is a (correct) way to access map-level information when inside individual topics in HTML transformations. If there is another way to go about accessing map-level information while processing individual topics in an XHTML transformation, perhaps that could help me get around this issue altogether.
Thanks for your attention to my issue.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: document() works in Oxygen but not from command line
Hi,
Not sure. If you run the "dita" command line with the "-v" flag outside of Oxygen does it report any kind of warning when that specific document() XSLT function is invoked?
Also if the "input.map.url" parameter is an URL, why are you prepending "file:/" to it?
Can you use an xsl:message to list the value of the $input.map.url parameter? Does it point to the original map or to the map inside the transformation temporary files folder?
Regards,
Radu
Not sure. If you run the "dita" command line with the "-v" flag outside of Oxygen does it report any kind of warning when that specific document() XSLT function is invoked?
Also if the "input.map.url" parameter is an URL, why are you prepending "file:/" to it?
Can you use an xsl:message to list the value of the $input.map.url parameter? Does it point to the original map or to the map inside the transformation temporary files folder?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9
- Joined: Fri Nov 27, 2020 5:52 pm
Re: document() works in Oxygen but not from command line
Hi Radu,
Your hunch was correct. There was an error message indicating that document() failed due to an IO issue and the file being locked. For some reason, when the transformation runs in Oxygen this error does not occur, but when I run from the command line with minimal parameter set, the error occurs.
At any rate, I have restructured the plugin using a preprocess extension point to create an additional temp file. I therefore no longer need to access the input map during the XHTML portion of the transformation and have avoided the issue altogether.
Thanks again for your help, Radu.
Your hunch was correct. There was an error message indicating that document() failed due to an IO issue and the file being locked. For some reason, when the transformation runs in Oxygen this error does not occur, but when I run from the command line with minimal parameter set, the error occurs.
At any rate, I have restructured the plugin using a preprocess extension point to create an additional temp file. I therefore no longer need to access the input map during the XHTML portion of the transformation and have avoided the issue altogether.
Thanks again for your help, Radu.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: document() works in Oxygen but not from command line
Hi,
I'm afraid I do not know why the original problem occurred, in recent Oxygen versions (probably 24.0 or newer) if you create a new DITA-OT transformation scenario Oxygen will run the transformation identically with how you would run it from the console, using the "dita.bat" executable so I would assume that the same problem would occur in Oxygen and in the command line.
I also do not understand why you prepended "file:/" to the "$input.map.url".
Regards,
Radu
I'm afraid I do not know why the original problem occurred, in recent Oxygen versions (probably 24.0 or newer) if you create a new DITA-OT transformation scenario Oxygen will run the transformation identically with how you would run it from the console, using the "dita.bat" executable so I would assume that the same problem would occur in Oxygen and in the command line.
I also do not understand why you prepended "file:/" to the "$input.map.url".
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service