I can't found some example how can I use argument -a when I use TextTransform.exe to generate code from templates. In MSDN is following description for argument -a:
"Specifies a parameter that a directive
processor can query for as a
name/value pair. The directive
processor and identifier are optional.
This allows parameters to be specified
for any directive processor or any
instance of a particular directive
processor."
I need some set of arguments like connection string and so on in my template. My idea was to get a path to configuration file with help of argument -a.
Regards
Anton Kalcik
UPDATE: To be clear enough, I want read parameters direct in template.
Text Template Transformation Toolkit(T4) is from Microsoft not very well supported. Only few examples. If you want to know more go to Olegs Sychs blog. T4 is here very deeply explained.
After of hours to trying to get parameters from TextTransform.exe in my template I found a solution:
Add hostspecific="true" attribute to template element as follows:
<## template language="C#v3.5" hostspecific="true"#>
Later in template you can call ResolveParameterValue as Oleg mentioned.
Example:
<#
string parameterTest = Host.ResolveParameterValue(null, null, "someKey");
WriteLine(parameterTest);
#>
You call template generator so:
"C:\Program Files\Common Files\Microsoft Shared\TextTemplating\1.2\TextTransform.exe" -a !!someKey!someValue
After generating should be in generated file: 'someValue'
The -a argument accepts values in the following format:
<ProcessorName>!<DirectiveID>!<ParameterName>
These are also the parameters of ITextTemplatingEngineHost.ResolveParameterValue method which you need to call in order to get parameter value in template code.
Related
I would like to generate dynamic text without the need to create webhooks whenever possible. I understand that the only way to create dynamic text is by either creating different routes depending on parameters or by using inline system functions like $sys.func.ADD(1, 2) within text fulfillments.
But inline system functions like $sys.func.ADD(1, 2) do not work for me if used in text fulfillments. System functions just don't get executed for me. I.e. instead of uttering "3" my bot just utters "$sys.func.ADD(1, 2)" as a result of a test fulfillemnt. What am I doing wrong here? Does anybody have an example for using inline system functions in text fulfillment?
Thanks!
To resolve this issue, you need to check the result of system functions in order to identify the error that occurred.
For the system function $sys.func.ADD, when using it as a text response in your fulfillment, you need to convert it to type STRING to be embedded in text since the output of this system function returns a type DOUBLE.
You can convert the output of the $sys.func.ADD function to STRING by creating a nested function in your text response and utilizing the $sys.func.TO_TEXT which converts a value of other types to string.
Here’s an example for reference:
I read https://www.blazemeter.com/blog/how-to-initialize-database-variables-and-assign-them-values-for-multiple-thread-groups
But I want to know if I can set the "Parameter values" value in the JDBC Prepared Select using the following technique, involving Set Variable or User Variables.
You can see that when I try this, I get the errors below.
Note: The following did work:
The correct syntax for __V() function would be:
${__V(consumer_id_${counter})}
If you're uncertain with the proper syntax go for the Function Helper Dialog
More information: Here’s What to Do to Combine Multiple JMeter Variables
I have not used Freemarker before and inherited some templates that won't compile. I have narrowed down the line that is causing problems to:
${text('Text and {0}', 'More Text')}
Where does this text() function come from? I understand that its trying to return the second string injected into the first like: "Text and More Text".
Here is the error:
FreeMarker template error:
For "...(...)" callee: Expected a method, but this has evaluated to an extended_hash (wrapper: f.t.SimpleHash):
modernizr-2.6.2.js is the only javascript imported.
Any ideas why this line is causing problems and where this function should be declared??
It can come from a few places:
From the data-model (one of the parameters you pass to Template.process)
From a shared variable, which is added to the Configuration singleton.
From an #include-d template (or from the template you are in), via #function text or #assign text = ... (or #global text = ...)
From an #import-ed template via #global text = ... (highly unlikely...)
But one potentially interesting thing is that the error says that text does exist, but it's a hash (a Map-like thing), not a callable thing. Maybe something that's also called text shadows the good text? What does ${.data_model.text('Text and {0}', 'More Text')} say?
You mention a JavaScript file. FreeMarker has nothing to do with JavaScript (and it runs on the server, inside the JVM).
The following Go template processes without error:
{{block "A" "hello"}}{{end}}
{{define "A"}}{{.}}{{end}}
The output is "hello", as I would expect from reading the documentation. In contrast, the following template does not parse:
{{block "A" "hello"}}A{{end}}
{{define "A"}}{{.}}{{end}}
Here I get the error message
template: multiple definition of template "A"
Why does the second template give an error while the first does not? Is this difference intended?
Complete code is here: https://play.golang.org/p/CNAqllVLjB
The answer lies in the doc of html/template.Parse():
[...] It is an error if a resulting template is non-empty (contains content other than template definitions) and would replace a non-empty template with the same name. (In multiple calls to Parse with the same receiver template, only one call can contain text other than space, comments, and template definitions.)
Your first template works because {{block "A"}} defines an empty template, and so it is allowed to be re-defined.
Your second template fails because {{block "A"}} defines a non-empty template and yet you try to re-define it with a non-empty template.
One thing to note here: I quoted the doc from the html/template package, which should be "identical" to text/template. It is most of the time, but text/template.Parse() is different, and leaves out this important detail, but they work the same way. This is a documentation inconsistency, filed an issue which can be tracked here: issue #17360.
Could you please help me on this xpath expression evaluation
I am working on fetching the proxy references. In the xml file the references will get stored as:
One way of XML file will have the reference as below:
con1:service ref="MyProject/ProxyServices/service1"
xsi:type="con2:PipelineRef" xmlns:ref="http://www.bea.com/wli/sb/reference"/
here in the xml file the name spaces are:
xmlns:con1="http://www.bea.com/wli/sb/stages/config"
xmlns:con2="http://www.bea.com/wli/sb/pipeline/config"
Another way of XML will have the reference as below.
con1:service ref="MyProject/ProxyServices/service2"
xsi:type="ref:ProxyRef" xmlns:ref="http://www.bea.com/wli/sb/reference"/
here in the xml file the name spaces are:
xmlns:con1="http://www.bea.com/wli/sb/stages/config"
xmlns:ref="http://www.bea.com/wli/sb/reference"
I have used this xpath expression, this is not fetching the reference service values, could you please help what is wrong in it.
"//service[#type= #*[local-name() ='ProxyRef' or #type=#*[local-name() ='PipelineRef']]/#ref"
when I used like this it is working but, name space prefix is keep on changes when there are multiple references in the xml file.
"//service[#type='ref:ProxyRef'or #type='con:PipelineRef' or #type='con1:PipelineRef' or #type='con2:PipelineRef' or #type='con3:PipelineRef' ...#type='con20:PipelineRef' ]/#ref";
Now here basically the type attribute PipelineRef is keep on changing the name space prefix from con to con(n). Now I am looking for something which supports some thing like #type='*:PipelineRef' or #type='con*:PipelineRef' or the best way to fetch the service element reference attribute value.
Thanks in advance.
Try using contains() like so :
//service[contains(#type,':ProxyRef') or contains(#type,':PipelineRef')]
Another alternative would be using ends-with() function which is more precise for this purpose compared to contains() function. However, ends-with() isn't available in xpath 1.0, so there is a chance that you need to implement it yourself (feasible, but the xpath result is less intuitive for me).