XML to URL Encoded (XSLT?)

I have some data in a Document object and need to convert it to URL encoded format so, for example this:
<share>
<code>GSK</code>
<price>13.34</price>
</share>
becomes something like...
&code=GSK&price=13.34& ...
I've been looking into doing this with XSLT but have run into difficulties. Do you think this is the best way of solving this problem, or is there another easier way?
Thanks.

I did something similar, basically takes a incoming XML file and output a HTML with certain link containing XML element value as query string. One of the things you have to be careful is, like Dr. Clap mentioned, to properly encode the value. I accompolished by using java extension in my XSL.
For example:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          xmlns:encode="java.net.URLEncoder"
          extension-element-prefixes="encode"
          version="1.0">
     <xsl:template match="/">
          <xsl:variable name="myURL" select="concat('?blah=', encode:encode($myValueFromXML))" >
     </xls:template>
</xsl:stylesheet>

Similar Messages

  • URL Encoding and Decoding in OSB

    Hi,
    Do we have out-of-box solution in OSB to decode XML which is URL encoded and encode XML to URL encoding. If so how can I do it.
    This might be basic question. I am unable to figure out. new to OSB.
    Thanks
    Sham.

    Hi Sham,
    Probably these are what you looking for...
    fn-bea:inlinedXML()
    fn-bea:serialize()
    fn-bea:serialize() to represent an XML document as a string
    fn-bea:inlinedXML() to parses textual XML and returns an instance of the XQuery 1.0 Data Model.
    Supported Function Extensions from Oracle
    http://docs.oracle.com/cd/E23943_01/admin.1111/e15867/xquery.htm#i1101407
    Oracle’s XQuery Implementation
    http://docs.oracle.com/cd/E13162_01/odsi/docs10gr3/xquery/extensions.html
    Cheers,
    Vlad
    It is considered good etiquette to reward answerers with points (as "helpful" - 5 pts - or "correct" - 10pts)
    https://forums.oracle.com/forums/ann.jspa?annID=893

  • Sending document to oracle xml gateway web service and body is url encoded

    Hello,
    a question from a complete newbie to web services. I have some code that is sending a soap message to an oracle xml gateway web service. In the soap message the values in the soap body look like &lt ;CNTROLAREA&gt ;
    when I would be expecting <CNTROLAREA>. What I have been told is that the content of the ReceiveDocument element has been url encoded which causes the &lt and to correct it I need to change the paramater type from object to xmlnode and to build the request as an xmldocument. The xmlnode and xmldocument comes from a .net guy so I've been trying to find the equivalent in java but am not having any luck. I have a lot of reading to do but was wondering if someone might be able to point me in the right direction on how to correct the problem. I captured the soap message being sent using tcpmon. Why does the body have the &lt instead of the < as I was expecting and is there an xmldocument type? The header part of the soap message looks as I expect. "><soapenv:Header><ns1:XMLGateway_Header xmlns:ns1="http://xmlns.oracle.com/apps/fnd/XMLGateway"><ns1:MESSAGE_TYPE>XML</ns1:MESSAGE_TYPE>. It is being sent as a com.oracle.xmlns.apps.fnd.XMLGateway.XMLGateway_Header type.
    thanks
    Thanks
    Edited by: twf123 on May 5, 2010 11:59 AM
    Edited by: twf123 on May 5, 2010 12:00 PM

    twf123 wrote:
    What I have been told is that the content of the ReceiveDocument element has been url encoded which causes the &lt and to correct it I need to change the paramater type from object to xmlnode and to build the request as an xmldocument. Where do you change the parameter type?
    The xmlnode and xmldocument comes from a .net guy so I've been trying to find the equivalent in java but am not having any luck. How do you get the data from .net guy? Which interface do you use? What processing do you do after receiving the data?

  • XSL and url encoded data issue

    I have a large XML document, which has the data in it URLEncoded to escape the nasty chars.
    When I run it through the xalan XSL parser and feed the output to the browser in my servlet, the resultant html has the URLEncoded chars in it. For instance the '/' is still showing up at %2F etc... However, if I can't URLDecode the whole xml document. Is there a simple way for decode the URL chars, without doing too much trickery?
    Thanks!
    Modoc

    You can URL-encode XML data if you like, whatever you mean by "nasty chars" I don't know. The result is perfectly legitimate XML and XSLT will translate it perfectly well. But it won't decode it, that is none of its business. I suppose it would be possible to write an XSLT function to do URL-decoding, but my preference would be to do that some other way. Or not to URL-encode in the first place.

  • How to populate XML schema details in XSLT output

    I want to print details about XML schema , xmlns on XSLT output as below.
    <?xml version="1.0" encoding="UTF-8"?>
    <CBISEDACReqLogMsg xsi:schemaLocation="urn:CBI:xsd:CBISEDACReqLogMsg.00.01.04 CBISEDACReqLogMsg.00.01.04.xsd"
    xmlns="urn:CBI:xsd:CBISEDACReqLogMsg.00.01.04" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    But in actual
    In my XSLT output I can see below.
      <?xml version="1.0" encoding="UTF-8" ?>
    - <CBISEDACReqLogMsg xmlns="urn:CBI:xsd:CBISEDACReqLogMsg.00.01.04">
    My XSLT is as code is below
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="2.0"
    xmlns:calendar="http://www.oracle.com/XSL/Transform/java/java.util.Calendar"
    xsl:schemaLocation="urn:CBI:xsd:CBISEDACReqLogMsg.00.01.04 CBISEDACReqLogMsg.00.01.04.xsd"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="urn:CBI:xsd:CBISEDACReqLogMsg.00.01.04"
    xmlns:string="http://www.oracle.com/XSL/Transform/java/java.lang.String"
    exclude-result-prefixes="calendar string">
      <xsl:output method="xml" indent="yes" encoding="UTF-8"></xsl:output>
      <xsl:template match="/">
    Kindly help me for how to show other required details in XSLT output.

    I am in the same boat. How do I disable XML Validation in NW BPM?
    In my case, Data comes from PI to NW BPM. But PI never cares about schema validation unless asked for. I have at least a 100 WSDLs that are failing to receive messages if I could not turn this off in BPM. I can not fix the Data Type as it is supported by third party.
    Any help is appreciated.
    VJ

  • XML message without encoding type

    Hi,
    Is there any possibility to generate the XML file without encoding?
    Should convert  <?xml version="1.0"; encoding="UTF-8"?> to <?xml version="1.0";?>. I have checked the blog and the answer was either Java mapping or XSLT mapping. Is it possible to handle in graphical mapping?
    I am using the AS2 adapter to send the file to customer and External defination for the target message. Below are few information on the AS2 configuration:
    Signing Algorithm: SHA-1
    Encryption: 3DES
    Your suggestion is highly appreciated.
    Regards,
    Vasantha

    HI Vasantha,
        It is not possible with Graphical Mapping you need to go either with JAVA or XSLT mapping.
    /people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
    Cheers!!!
    Naveen

  • XML export, while applying XSLT, gives a jumbled mess

    From InDesign, I export to XML and apply an XSLT which transforms it into HTML. Trying to edit the document is almost impossible because the whole thing is a few giant lines of code.
    What's going on with this behaviour?
    Can Dreamweaver view it correctly?

    My two cents:
    Recently I wrote a script that creates xml structure in a document by performing a number of find-replace GREP operations instead of using map styles to tags or manual tagging.
    One of the problems I encountered was the following: if an element contained more than one paragraph, all returns disappeared after exporting to xml file. I solved this by writing an xml-rule that adds <p> tags so a browser displays them as separate paragraphs.
    if (gDoc.xmlTags.item("p") != null) {
         gParTag = gDoc.xmlTags.item("p");
    else {
         gParTag = gDoc.xmlTags.add("p");
    var ruleSet = new Array ( new ProcessParagraphs, new ProcessImageAttributes ); // new ProcessParagraphs, new ProcessImageAttributes
    with(gDoc){                    
         var elements = xmlElements;
         __processRuleSet(elements.item(0), ruleSet);
    function ProcessParagraphs() {
         gWinText1.text = "Adding paragraph returns";
         gWinText2.text = "";
         var theParagraph, fistCharIndex, fistChar, lastChar, text;
         this.name = "ProcessParagraphs";
         if (gVariant == 3) {
              this.xpath = "/Root/AvisosPublicados/Rubro/Subrubro/Aviso/*";
         else {
              this.xpath = "/Root/Rubro/Aviso/*";
         this.apply = function(theElement, theRuleProcessor) {
              with(theElement) {
                        //$.writeln("#" + gElCounter + " - Element Name = " + theElement.markupTag.name + " - " + theElement.paragraphs.length + " pars");    
                        //gElCounter++;
                   if (theElement.paragraphs.length > 1) {
                        for (var i = 0; i < theElement.paragraphs.length; i++) {
                             theParagraph = theElement.paragraphs[i];
                             //$.writeln( "\t" + gCounter + "/" + i + " - " + theElement.markupTag.name + " - " + theParagraph.associatedXMLElements[0].markupTag.name + " - " + theParagraph.contents );
                             if (theParagraph.associatedXMLElements[0].markupTag.name != "Tabla") {
                                  fistCharIndex = 0;
                                  lastCharIndex  = -2;
                                  try {
                                       while (theParagraph.characters[fistCharIndex].contents.constructor.name == "Number" || theParagraph.characters[fistCharIndex].contents.charCodeAt(0) == 65279) {
                                            fistCharIndex++;
                                            while (theParagraph.characters[lastCharIndex].contents.constructor.name == "Number" || theParagraph.characters[lastCharIndex].contents.charCodeAt(0) == 65279) {
                                            lastCharIndex--;
                                  catch(err) {
                                       //$.writeln("\tError (fist/lastCharIndex++) = " + err);
                                       continue;
                                  //$.writeln("\tfist/last = " + fistCharIndex + "/" + lastCharIndex);
                                  fistChar = theParagraph.characters[fistCharIndex];
                                  lastChar = theParagraph.characters[lastCharIndex];
                                  text = theParagraph.texts.itemByRange( fistChar, lastChar )
                                  //$.writeln(gCounter + "/" + i + " - " + theElement.markupTag.name + " - " + text.contents);
                                  theElement.xmlElements.add( gParTag, text );
    //~                               gCounter++;
         return true;
    I also wrote a function that removes undesirable stuff from the resulting xml file, including entities (I don’t know the reason why, but my client asked me to remove them)
    function ProcessXmlFile(file) {
         gWinText1.text = "Processing the XML file";
         gWinText2.text = "";
         file.open("r");
         var txt = file.read();
         file.close();
         txt = txt.replace(/&#822(0|1);/g, "\""); // Double left and right quotation marks ==> "
         gWinText2.text = "Double left and right quotation marks";
         txt = txt.replace(/&#821(6|7);/g, "'"); // Single left and right quotation marks ==> '
         gWinText2.text = "Single left and right quotation marks";
         txt = txt.replace(/&#8211;/g, "–"); // En dash ==> – Alt+0150
         gWinText2.text = "En dash";
         txt = txt.replace(/&#8212;/g, "—"); // Em dash ==> — Alt+0151
         gWinText2.text = "Em dash";
         txt = txt.replace(/&#8226;/g, "•"); // Bullet ==> • Alt+0149
         gWinText2.text = "Bullet";
         txt = txt.replace(/&#169;/g, "©"); // Copyright ==> © Alt+0169
         gWinText2.text = "Copyright";
         txt = txt.replace(/&#8230;/g, "…"); // Ellipsis ==> … Alt+0133
         gWinText2.text = "Ellipsis";
         txt = txt.replace(/&#182;/g, "¶"); // Pilcrow (paragraph) ==> ¶ Alt+0182
         gWinText2.text = "Pilcrow";
         txt = txt.replace(/&#174;/g, "®"); // Registered trademark ==> ® Alt+0174
         gWinText2.text = "Registered trademark";
         txt = txt.replace(/&#167;/g, "§"); // Registered trademark  ==> § Alt+0167
         gWinText2.text = "Registered trademark";
         txt = txt.replace(/&#8482;/g, "™"); // Trademark ==> ™ Alt+0153
         gWinText2.text = "Trademark";
         file.open("w");
         file.encoding = "UTF-8";
         file.write(txt);
         file.close();

  • Unescaping URL Encoded Strings

    Anyone know how to unescape URL encoded strings using XSL? I can use the translate() function to replace the + signs with spaces but the %3F and %3E style characters are causing problems. The escaped characters are in an XML doc.
    Any help would be appreciated.

    Anyone know how to unescape URL encoded strings using XSL? I can use the translate() function to replace the + signs with spaces but the %3F and %3E style characters are causing problems. The escaped characters are in an XML doc.
    Any help would be appreciated.

  • Reverse the url-encoded process

    Hi there,
    Is it possible to flash rebuild a string that as been
    url-encoded?
    Thanks,

    Hi David thanks for your reply.
    It seems that my problem is not url-encoded.
    I have a flash with a sendAndLoad vars to a coldfusion file.
    The coldfusion is suppose to return a XML object. Instead it
    returns a
    String because the XML special characters [ <, >, " ]
    are converted to
    [&lt;, &gt;, &quot;].
    I think this problem is because you can have a programming
    language based on
    tags directly written in coldfusion (also a programming
    language based on
    tags). Like when you write html formatting text in an xml
    structure. The xml
    structure will assume tags like <br/> as a child Node
    instead of a tag
    content.
    So I had to make some functions to replace special characters
    in a string.
    I don't agree with this solution, but it was the only thing I
    came up with.
    Thanks
    "David Stiller" <[email protected]> wrote in
    message
    news:e63u3m$oug$[email protected]..
    > SteveStall,
    >
    >> Is it possible to flash rebuild a string that as
    been url-encoded?
    >
    > You betcha. The escape() function url-encodes strings;
    the unescape()
    > function url-decodes strings.
    >
    >
    > David
    > stiller (at) quip (dot) net
    > Dev essays:
    http://www.quip.net/blog/
    > "Luck is the residue of good design."
    >

  • Remove xml declarations when using xslt

    Hi, i have created an xslt which transforms an xml file and then imports the information into a mysql database. It works and imports the information into the database but it also brings across the xml delcarations and the node names.
    Is there a coldfusion way to remove these declarations, all i want is the information itself brought into the database.
    Thanks
    Chris

    Hi Adam,
    here is the code from the xsl file:
    <?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="data/itemfeed.xml" --><!DOCTYPE xsl:stylesheet  [
        <!ENTITY nbsp  "&#160;">
        <!ENTITY copy  "&#169;">
        <!ENTITY reg    "&#174;">
        <!ENTITY trade  "&#8482;">
        <!ENTITY mdash  "&#8212;">
        <!ENTITY ldquo  "&#8220;">
        <!ENTITY rdquo  "&#8221;">
        <!ENTITY pound  "&#163;">
        <!ENTITY yen    "&#165;">
        <!ENTITY euro  "&#8364;">
    ]>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
    <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    </head>
    <body>
    <xsl:for-each select="Items/Item[ItemType='Standard']">
    <xsl:value-of select="EANNumber"/>
    </xsl:for-each>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>
    And here is some sample data from the XML file:
    <?xml version="1.0" encoding="UTF-8" ?>
    <Items>
        <Item>
            <ItemType>Standard</ItemType>
            <EANNumber>111222333444</EANNumber>
        </Item>
    </Items>
    Thanks alot, i appreciate the help.
    Chris

  • URL encoder for NSString?

    My goal is to send NSString data in an xml format. Is there a way of encode non ascii chars to survive the xml transfer (like an url encoder but at string level)?

    OK, my bad. I had the wrong encoding on the incoming reply not the response.
    Issue solved.
    NSString *reply = [[NSString alloc]initWithBytes:[myMutableData mutableBytes] length:[myMutableData length] encoding:NSUTF8StringEncoding];

  • Newbie ERROR- URL Encoded SQL Length exceeds allowed 32K limit

    My SQL Query worked fine yesterday.( I'm still in developing mode)
    I made a copy of it and put it into a text file.( Just to be sure I had it.)
    Today When I tried to run it in APEX , I get error
    URL Encoded SQL Length exceeds 32K limit.
    Is there any way to tell how the size of my query ( for example 33K)
    is using?
    TIA
    Steve42

    I had to put out some other fires for the last few days.
    I'm trying to use it in SQL worksheet.
    That is my entire error message. It does NOT have an Error #.
    Product Build: 3.0.0.00.20
    TIA,
    Steve42

  • Hi, how to use URL encoding in jsp

    hi, how to apply URL encoding in jsp for a string, could u pls suggest some ideas to use URL encoding in jsp
    thank you in advance

    hi, thnx for the reply, but my problem is to use url encoding method
    i would u like to know how to represent in jsp program i have asp code some thing like this
    href='/project/tel_number.asp?team=<%=DbRecTeam("id")%>&name=<%=Server.URLEncode(DbRec("name"))%>'
    i would like to know how replace that Server.URLEncode stmt in jsp, could u pls suggest some equivalent method for the above stmt
    thanx in advance

  • URL Encoding and UTF8

    Hello Friends,
    I have been working on this problem for some time now. I have a web page that has forms fields like first name, last name etc. and then posts the data back to a servlet that writes it into a file that is utf-8 encoded. The web page has charset specified as utf-8. I was assuming that data would be sent back in the url as utf-8. I entered some japanese data copied from a japanese web page. When I looked at the file into which the form data was written I saw that it wasn't even close to utf-8 or unicode encoding of the data I had posted. For eg. I entered a japanese character: '\u4F1A' which is utf-8 encoded as 'E4 BC 9A'. But the data written into the file is '25 45 34 25 42 43 25 39 41'. This is of course because the data is url encoded which is '%E4%BC%9A', since 45 is hex for E, 34 is hex for 4 and so on. Now the question is how is it that I proceed to get the right utf data back. I am using a jrun server. Is there something that I need to set here in order to get the right characters back.

    The UTF-8 encoded sequence of bytes of the character '\u4F1A' is {-E4, -BC, -9A}, and the character '-' is (char)0x2d instead of (char)0x25. And I suppose 25 should be 2d.

  • URL Encoder not working in Netscape

    Hi All,
    I am using url encoding in my servlet for redirecting a request. The query string values has some spaces in them. The code I have used is shown below
    String mname = "Jason Perry"
    response.sendRedirect
    ("http://194.216.8.238:8081/merchant/merch.merchant?msgid=RP&mctid=1111242&totcp="+price.toString()+"&mname="+URLEncoder.encode(mname)+"&mtxnid=UY675432");
    Please note that 194.216.8.238:8081 is an IP of another server located outside our network.
    In Netscape the url is shown as http://194.216.8.238:8081/merchant/merch.merchant?msgid=RP&mctid=1111242&totcp=15
    &mname=Jason Perry&mtxnid=UY675432
    The space is not getting replaced with the plus.
    But I have observed that if the redirection is to the same server on which the servlet is running, it works fine.
    I am at loss as to why url encode is not working when routing the request to another server. I am using Netscape 4.77 .
    This is works in IE fine.
    Your inputs are appreciated.
    Thanks
    Malini

    Yeah had this problem before, use the java.net.URLEncoder class:
    <%@ page language="java" import="java.net.URLEncoder"%>
    <%
    String url = "http://194.216.8.238:8081/merchant/merch.merchant?msgid=RP&mctid=1111242&totcp=15
    &mname=Jason Perry&mtxnid=UY675432"
    String encodedUrl = URLEncoder.encode(url);
    response.sendRedirect(encodedUrl);
    %>

Maybe you are looking for