I am in the process of converting a file written in XSLT 2.0 to XSLT 1.0 so that it can be used in a browser. Would anyone know how to implement something with the same functionality as fn:Qname using only XSLT 1.0?
fn:QName delivers a value of type xs:QName, and there is no such data type in XSLT 1.0, so there can be no equivalent function. You'll have to start by deciding on an alternative representation of QNames: for example you could use the XPath 3.0 notation "Q{uri}local", held as a string. (The xs:QName type also holds a namespace prefix, you need to decide whether you need to do that.)
Assuming you decide to use the representation "Q{uri}local" and that namespace prefixes are not required, implementing an equivalent of fn:QName can then be done straightforwardly using functions such as concat(), contains(), and substring-after().
Related
What is the difference between reading the properties from payload. for example there is a property in the payload which is named as con_id. when i read this property like this #[payload.con_id] then it is coming as null. where as #[payload.'con_id'] is returning the value.
few other notations which i know of is #[payload['con_id']] or #[json:con_id]
which one should be used at which scenario? if there are any special cases to use any specific notation then please let me know the scenario also.
Also, what is the common notation that has to be used from a mule soft platform supported point of view.
In Mule 3 any of those syntax are valid. Except the json: evaluator is for querying json documents where as the others are for querying maps/objects. Also the json: evaluator is deprecated in Mule 3 in favor of transforming to a map and using the MEL expressions below.
payload.property
payload.'property'
payload['property']
The reason the first fails in your case, is beacaue of the special character '_'. The underscore forces the field name to be wrapped in quotes.
Typically the . notation is preferred over the [''] as its shorter for accessing map fields. And then simply wrap property names in '' for any fields with special chars.
Note in Mule 4, you don't need to transform to a map/object first. Dataweave expression replace MEL as the expression language and allow you to directly query json or any type of payload without transforming to a map first.
In my project we have a requirement where we have to insert an array of struct as an input parameter.How i can achieve that.
I don't want to use the approach suggested here
https://dzone.com/articles/passing-java-arrays-in-oracle-stored-procedure-fro
I want to use the inbuilt objects given in mule.
we have to insert an array of struct as an input parameter
Where you want to insert this array ?
array of struct
can we consider the User defined data type as POJOs ( just java object?) ?
I want to use the inbuilt objects given in mule.
As I can see in the link, the example use Java + Mule component. Should I guess that you want to avoid Java code?
Please, elaborate your use case... hard to replicate
I have an API written in Swagger 2.0 that says an entity has a property called when of type date-time:
properties:
when:
type: string
format: date-time
I don't know how to parse the string. How should I expect the date-time format to looks like? I cannot find this in the Swagger 2.0 documentation
As per the Open API 2.0 spec, the date-time should be defined by RFC3339.
For example:
2016-03-22T21:03:41
1985-04-12T23:20:50.52Z
1990-12-31T15:59:60-08:00
I don't know how to parse the string.
This would depend on the language you're using. In JavaScript, Date.parse(dateString) can easily parse the string. Or in Java, you can refer to Converting ISO 8601-compliant String to java.util.Date to know how to parse the date string.
I have been using different forms of Mule's Expression language.
I couldn't figure out the difference between
#[flowVars.myVariable]
and
#[flowVars['myVariable']]
They both give the result when there is a variable. But why do they behave differently when the variable is not present?
Like if the variable being called is not available, then the first expression would result in a exception. Whereas the second expression just gives out a warning or prints out as is, if in a logger message.
Why is this difference?
Also when going through the documentation for Mule 3.6 I found that the second expression is not longer shown in the documentation.
Is the expression #[flowVars['myVariable']] being deprecated?
The difference comes from the way MVEL deals with these two different ways of accessing map entries.
#[flowVars['myVariable']] is equivalent to flowVars.get('myVariable'), which does not fail if the flowVars map does not contain the 'myVariable' entry,
#[flowVars.myVariable] treats the flowVars map as a virtual object, leading to an exception if the 'myVariable' entry is missing because in this case it doesn't resolve to a map get but instead to directly using an object member (either a field or a method), which must exist before being accessed.
I don't think #[flowVars['myVariable']] could be deprecated since it's a core feature provided by MVEL.
Reference: http://mvel.codehaus.org/MVEL+2.0+Property+Navigation#MVEL2.0PropertyNavigation-MapAccess
David has given a nice explanation around your question. To extend that explanation I would just like to add that you can use #[flowVars.?myVariable] to make your code null safe. This is equivalent to #[flowVars['myVariable']].
Regarding #[header:originalFilename], as David said this is not MEL. You can get a list of non-mel expressions which are commonly used in Mule applications in the following link.
http://www.mulesoft.org/documentation/display/current/Non-MEL+Expressions+Configuration+Reference
According to this:
http://www.xmlplease.com/xquery-xhtml
"XQuery does not have a standard way of setting the serialization parameters if available. In XQuery we must look up the proper documentation for the XQuery processor to find out what serialization parameters are implemented if any, and how exactly to use them. If available they can normally be set at the command line. Often they can also be used from inside the XQuery document."
In Saxon you can write something like
declare option saxon:output "omit-xml-declaration=yes";
But there is no mention on how to do it in Zorba XQuery. Can you help? Thank you.
Zorba doesn't implement the XQuery 3.0 prolog options for serialization, yet.
The only way to configure the serializer is using the command line interface (e.g. --omit-xml-declaration) or a host language (e.g. the C++ API).
XQuery_t lQuery = aZorba->compileQuery("for $i in (1 to 3) return <a> { $i } </a>");
Zorba_SerializerOptions lSerOptions;
lSerOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
lQuery->execute(std::cout, &lSerOptions);
Alternatively, you could explicitly serialize the result to a string
fn:serialize($result,
<output:serialization-parameters>
<output:indent value="yes"/>
<output:method value="xml"/>
<output:omit-xml-declaration value="yes"/>
</output:serialization-parameters>
)
and then use the text serialization method (--serialize-text) in the command line interface to output this string.
This is the new official XQuery 3.0 syntax, which is already supported by some XQuery implementations (so I guess it will be implemented in Zorba soon?):
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:omit-xml-declaration "yes";
"your query"
According to the docs ( http://www.zorba-xquery.com/html/documentation/2.1.0/zorba/indexpage#w3cspecs ) Zorba should support the Serialization spec ( http://www.w3.org/TR/xslt-xquery-serialization/#serparam ). In that case it should, if I am not mistaken, be:
declare option omit-xml-declaration "yes";
HTH!
I think zorba doesn't use options to set serialisation parameters. Instead, you'll have to set those parameters as parameters of the serialisation function you're using.
For example, to serialize some XML to a file using zorba 2.x, you culd use the file:write() function. This function takes three parameters:
the file to write to,
the content to write,
and the serialisation parameters:
EDIT: I think it would look like this:
file:write (
'/tmp/test.xml',
$content,
<serialization-parameters>
<omit-xml-declaration>yes</omit-xml-declaration>
</serialization-parameters>
)
This is similar to zorba's 1.4.0 version that offered a generic function ser:serialize() in the serialize module. In general, this is not only application-specific but also version-specific so it may be helpful to know the zorba version you're using.
EDIT: If you're using the command line utility, you can use the option --serialization-parameter, -z to set serialisation parameters:
zorba -z omit-xml-declaration=yes -f -q my_xquery.xq