ShaileshShinde
asked on
Converting Operators into Hexadecimal
Hello Experts,
I have an input xml file which contains Operators like below....
<test symbol=","/>
<test symbol=":"/>
<test symbol="!"/>
<test symbol="!="/>
<test symbol="!=="/>
<test symbol="?:"/>
<test symbol="//"/>
<test symbol="/"/>
<test symbol="/*..*/"/>
<test symbol="/="/>
<test symbol="."/>
<test symbol="^"/>
<test symbol="^="/>
<test symbol="~"/>
<test symbol="""/>
<test symbol="()"/>
<test symbol="--"/>
<test symbol="-"/>
<test symbol="[]"/>
<test symbol="{}"/>
<test symbol="*"/>
<test symbol="*="/>
<test symbol="&"/>
<test symbol="&&"/>
<test symbol="&&="/>
<test symbol="&="/>
<test symbol="%"/>
<test symbol="%="/>
<test symbol="+"/>
<test symbol="++"/>
<test symbol="+="/>
<test symbol="<"/>
<test symbol="<<"/>
<test symbol="<<="/>
<test symbol="<="/>
<test symbol="="/>
<test symbol="-="/>
<test symbol="=="/>
<test symbol="==="/>
<test symbol=">"/>
<test symbol=">="/>
<test symbol=">>"/>
<test symbol=">>="/>
<test symbol=">>>"/>
<test symbol=">>>="/>
<test symbol="|"/>
<test symbol="|="/>
<test symbol="||"/>
<test symbol="||="/>
<test symbol="/"/>
<test symbol=".."/>
<test symbol="@"/>
<test symbol="{ }"/>
<test symbol="[ ]"/>
<test symbol="< >"/>
<test symbol=".."/>
<test symbol="( )"/>
<test symbol="+"/>
<test symbol="+="/>
<test symbol="::"/>
I would like to output xml file which will contains these operators hexadecimal values like below for example...
<conv>,</conv>
<conv>:</conv>
<conv>!</conv>
I have an input xml file which contains Operators like below....
<test symbol=","/>
<test symbol=":"/>
<test symbol="!"/>
<test symbol="!="/>
<test symbol="!=="/>
<test symbol="?:"/>
<test symbol="//"/>
<test symbol="/"/>
<test symbol="/*..*/"/>
<test symbol="/="/>
<test symbol="."/>
<test symbol="^"/>
<test symbol="^="/>
<test symbol="~"/>
<test symbol="""/>
<test symbol="()"/>
<test symbol="--"/>
<test symbol="-"/>
<test symbol="[]"/>
<test symbol="{}"/>
<test symbol="*"/>
<test symbol="*="/>
<test symbol="&"/>
<test symbol="&&"/>
<test symbol="&&="/>
<test symbol="&="/>
<test symbol="%"/>
<test symbol="%="/>
<test symbol="+"/>
<test symbol="++"/>
<test symbol="+="/>
<test symbol="<"/>
<test symbol="<<"/>
<test symbol="<<="/>
<test symbol="<="/>
<test symbol="="/>
<test symbol="-="/>
<test symbol="=="/>
<test symbol="==="/>
<test symbol=">"/>
<test symbol=">="/>
<test symbol=">>"/>
<test symbol=">>="/>
<test symbol=">>>"/>
<test symbol=">>>="/>
<test symbol="|"/>
<test symbol="|="/>
<test symbol="||"/>
<test symbol="||="/>
<test symbol="/"/>
<test symbol=".."/>
<test symbol="@"/>
<test symbol="{ }"/>
<test symbol="[ ]"/>
<test symbol="< >"/>
<test symbol=".."/>
<test symbol="( )"/>
<test symbol="+"/>
<test symbol="+="/>
<test symbol="::"/>
I would like to output xml file which will contains these operators hexadecimal values like below for example...
<conv>,</conv>
<conv>:</conv>
<conv>!</conv>
if you use MSXML processor, you can embed a JavaScript section to convert your input data to the hex form.
ASKER
Hello Experts,
Can you pls show some sample for this?
Is this possible using xslt 2.0 only?
Thanks,
Shailesh
Can you pls show some sample for this?
Is this possible using xslt 2.0 only?
Thanks,
Shailesh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello Experts,
This looks good for me. I will test it and let you know.
Thanks,
Shailesh
This looks good for me. I will test it and let you know.
Thanks,
Shailesh
ASKER
Hello Experts,
While transforming I am getting following errors....
Error at xsl:value-of on line 291 of file:/D:/parse.xslt:
XPST0017: XPath syntax error at char 27 on line 291 in {js:convert(string(@symbol ))}:
Cannot find a matching 1-argument function named {http://mycompany.com/mynamespace}convert()
Failed to compile stylesheet. 1 error detected.
Can you please suggest what's wrong with this or do I missed something?
Thanks,
Shailesh
While transforming I am getting following errors....
Error at xsl:value-of on line 291 of file:/D:/parse.xslt:
XPST0017: XPath syntax error at char 27 on line 291 in {js:convert(string(@symbol
Cannot find a matching 1-argument function named {http://mycompany.com/mynamespace}convert()
Failed to compile stylesheet. 1 error detected.
Can you please suggest what's wrong with this or do I missed something?
Thanks,
Shailesh
There is no XSLT2 implementation in msxml.
The javascript solution will not work for you
You can in XSLT2 create a lookup table as some XML in a variable
and use XPath to access the correct Hex value
In XSLT2 it is worthwhile to evaluate character maps to do what you need
The javascript solution will not work for you
You can in XSLT2 create a lookup table as some XML in a variable
and use XPath to access the correct Hex value
In XSLT2 it is worthwhile to evaluate character maps to do what you need
the sample I provided works only in MSXML implementation