Get username
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 28
- Joined: Thu Mar 12, 2009 4:16 am
Get username
Post by Rumplestiltzkin »
Is there any way I can get the windows username of the user running a stylesheet?
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Get username
Hello,
You can't do this in the stylesheet, the username has to be obtained from outside. You can either write a Java extension function that obtains it and then invoke this extension in the stylesheet to obtain it for you or you can obtain the username from outside before the transformation and pass it to the stylesheet as a parameter.
The first is a bit more complicated and involves a bit of Java code.
The second is a lot more simple and can be easily used in Oxygen:
- add to your stylesheet a new param: <xsl:param name="username"/>
- use the $username parameter as you need in the stylesheet.
- In Oxygen configure your transformation scenario: Document -> Transformation -> Configure Transformation Scenario, press Parameters and add(or edit if you can already see it listed) your parameter(username) and give it the value: ${system(user.name)}
When you apply the transformation Oxygen will evaluate the "user.name" Java system property and pass it to the stylesheet as the "username" parameter.
Regards,
Adrian
You can't do this in the stylesheet, the username has to be obtained from outside. You can either write a Java extension function that obtains it and then invoke this extension in the stylesheet to obtain it for you or you can obtain the username from outside before the transformation and pass it to the stylesheet as a parameter.
The first is a bit more complicated and involves a bit of Java code.
The second is a lot more simple and can be easily used in Oxygen:
- add to your stylesheet a new param: <xsl:param name="username"/>
- use the $username parameter as you need in the stylesheet.
- In Oxygen configure your transformation scenario: Document -> Transformation -> Configure Transformation Scenario, press Parameters and add(or edit if you can already see it listed) your parameter(username) and give it the value: ${system(user.name)}
When you apply the transformation Oxygen will evaluate the "user.name" Java system property and pass it to the stylesheet as the "username" parameter.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 156
- Joined: Sat Feb 26, 2005 12:09 am
- Location: USA
- Contact:
Re: Get username
Post by shudson310 »
Does this also work for schematron? Is there a way to get the current user in schematron?
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
Staff Content Engineer
Site: docs.servicenow.com
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Get username
Hello,
Yes, you can obtain the current user name also in Schemtron. You have two solutions:
Octavian
Yes, you can obtain the current user name also in Schemtron. You have two solutions:
- The first one is to use the "system-property()" function, something like this:
We are using Saxon processor to validate an XML with a Schematron schema, and Saxon implementation of the "system-property()" function will return also the value of a Java system property.
Code: Select all
<xsl:value-of select="system-property('user.name')"/>
http://www.saxonica.com/html/documentat ... perty.html - The second solution is to implement a Java extension function, as Adrian also explained, and add the JAR file in the extension dialog from the the Schematron validation scenario.
https://www.oxygenxml.com/doc/versions/ ... nario.html
Octavian
Octavian Nadolu
<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