Applying XSL on a XML string

Hi,
I am a newbie to XML and XSL.
I am getting an XML as a String, I want to apply a XSL on it.
a) Because I don't have any StreamSource can I apply an XSL on that String directly, Is there any API for it?
b) If we cannot apply directly on a String then how to address this issue?
This may be very common issue, but I am not getting any help on it.
Please help me on this?
Thanks in advance
Vikas

Yes, it's a very very common question here. I am surprised you didn't find the answer when you searched the forum because it is very very often posted.
I don't know why you say you don't have a StreamSource. Why don't you just create one?
new StreamSource(new StringReader(yourXMLString))

Similar Messages

  • Error applying XSL stylesheet to XML

    Hi,
    after installed SPS 21 into portal we are facing an issue:
    A contentadministrator wants to publish a new newsfact in portal, but get the following error message:
    Error applying XSL stylesheet to XML:
    com.sapportals.wcm.WcmException: com.sap.engine.lib.xml.util.NestedException: Variable '$system_config_activateClipboard' has not been bound to a value
         at com.sapportals.wcm.service.pipeline.Pipeline.handle(Pipeline.java:284)
    Hope that somebody can give me some help.
    thanks a lot in advance.
    Regards,
    Edwin

    Hi Lorcan,
    You help solved our issue, thanks a lot.
    After generate the existing xml project with the Forms builder in the Content Management,
    the contentadministratoris able to produce a new newsfact without errors
    Regards, edwin
    Posts: 123
    Registered: 11/29/04
    Forum Points: 346 
    Solved problem (10)
    Very helpful answer (6)
    Helpful answer (2)
       Re: Error applying XSL stylesheet to XML  
    Posted: Apr 19, 2010 11:13 AM    in response to: Edwin Theuns           Reply 
    Hi Edwin,
    You need to recompile the xml forms project and that should resolve the issue. Unfortunately there is no alternative solution in such a scenario.
    Regards,
    Lorcan.

  • XML forms error: Error applying XSL stylesheet to XML

    hi,
    I created XML forms for news and 2 weeks ago everything was working right, but today when i try to see a preview of the project i get this error:
    XML - Forms 
    <b>Error applying XSL stylesheet to XML</b>
    com.sapportals.wcm.WcmException: com.sap.engine.lib.xml.util.NestedException: Variable '$Sap' has not been bound to a value
    at com.sapportals.wcm.service.pipeline.Pipeline.handle(Pipeline.java:284)
    at com.sapportals.wcm.service.pipeline.XSLTPipeline.handle(XSLTPipeline.java:118)
    at com.sapportals.wcm.service.xmlforms.transformation.Transformer.pipeIt(Transformer.java:133)
    at com.sapportals.wcm.service.xmlforms.transformation.Transformer.transform(Transformer.java:105)
    at com.sapportals.wcm.service.xmlforms.transformation.Transformer.transform(Transformer.java:77)
    at com.sapportals.wcm.service.xmlforms.transformation.HtmlGenerator.getHtmlStream(HtmlGenerator.java:122)
    at com.sapportals.wcm.service.xmlforms.transformation.Transformation.render(Transformation.java:391)
    I really don't know where this come from is there somebody that can help me?
    i tried to change the paths of the project cause i also got this:
    <b>java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key xmsg_project_not_exist</b>
    at java.util.ResourceBundle.getObject(ResourceBundle.java:326)
    at java.util.ResourceBundle.getObject(ResourceBundle.java:323)
    at java.util.ResourceBundle.getString...
    Hope that somebody can give me some help. Please it is urgent we have to deploy the site this week.
    thanks a lot in advance.
    Regards,
    MJ

    Hi All,
    Anybody could find the cause for this?
    I'm also facing the same problem now when I try to see the preview for Edit Form. It's working fine with RederList Form. Earlier everything was fine. If somebody has got the solution for this, pls help me out. This is very urgent. Thankyou very much in advance.
    Thanks & BR,
    Ram Marni.
    [email protected]

  • How to apply Xsl to the xml value stored in ResultSet

    String url = "jdbc:msql://200.210.220.1:1114/Demo";
    Connection conn = DriverManager.getConnection(url,"","");
    Statement stmt = conn.createStatement();
    ResultSet rs;
    rs = stmt.executeQuery("SELECT Lname FROM Customers for auto xml");
    // I want to convert the content of this rs into a String or StringBuffer and apply sxlt to format the data. Can anyone help me.
    Thanks

    In your view you could do something like that:
    foreach (var field in Model.FormStruture.fields)
    <div class="editor-label">
    <label for="@field.Name">@field.Descricao</label>
    </div>
    <div class="editor-field">
    <input class="text-box single-line" id="@field.Name" name="@field.Name" type="text" value="@field.Valor" data-rules-required="@field.Mandatory.ToString().ToLower()" data-rule-number="@field.Tipo.Equals(SiB.OCR.Documentos.Modelo.TipofieldDocumento.Numerico).ToString().ToLower()" title="@field.Descricao" />
    </div>
    if (!String.IsNullOrEmpty(field.Format))
    @:<script type="text/javascript">$("[email protected]").mask("@field.Format");</script>

  • Converting SQL Server text field containing XML string to XI XML via JDBC

    Hello
    My client has a SQL Server database containing a field of type Text which contains an XML string e.g.
    <DispatchJob> <DispatchDateTime>2003-09-29T13:29:15</DispatchDateTime> <AssignedFSE>F118</AssignedFSE> <DispatchJobPurchase> <DealerID>14C5</DealerID> <DateOfPurchase>1997-10-01T00:00:00</DateOfPurchase> </DispatchJob>
    I am using JDBC to access this but could someone please recommend the best and easiest solution for converting this string to XI XML for subsequent mapping to BAPI or IDOC or ABAP Proxy and transmission to SAP. There are other fields as well in the database table so thoughts at the moment are to use a normal graphical message mapping followed by an XSL mapping. Will an XSL mapping be able to do this and if so is that the best solution?
    Also I need to do the reverse of this and take fields coming from SAP via BAPI,IDOC etc. and convert them to a single database table field as an XML string also via the JDBC adapter. What is the best way to do this. Could it be done simply with functions in the graphical mapping e.g. concatenate?
    Thank you in advance.
    Trevor

    Hi Michal
    Thanks for the prompt reply.
    I was anticipating XSLT for reading from the SQL Server database and converting the XML string.
    But how would you convert the individual fields from SAP into a single field as an XML string for storing in the SQL Server database? What approach would you use?
    Regards
    Trevor

  • Parsing an xml string into id-value pair format

    Hi,
    I am new in oracle BPEL.
    My requirement is that I need to parse an xml string containing tag name and coressponding value into an 'id -value' pair.
    For example-
    The input xml format is -
    <employee>
    <empid>12345</empid>
    <name>xyz</name>
    <city>London</city>
    </employee>
    The required xml format is-
    <employee>
    <item id="empid" value="12345"/>
    <item id="name" value="xyz"/>
    <item id="city" value="London"/>
    </employee>
    Please let me know if there is a work-around for this.
    Thanks

    Something like this (have not tested):
    <xsl:for-each select="//employee">
    <employee>
    <xsl:for-each select="./*">
    <item>
    <xsl:attribute name="id">
    <xsl:value-of select="name()"/>
    </xsl:attribute>
    <xsl:attribute name="value">
    <xsl:value-of select="text()"/>
    </xsl:attribute>
    </item>
    </xsl:for-each>
    </employee>
    </xsl:for-each>

  • Convert XML string into XML

    Hi All,
    Can you please let me know for any sample code in xslt/java mapping for converting XML string into XML. We use SAP Pi 7.0
    My XML string starts like this
    <?xml version="1.0" encoding="UTF-8" ?> 
    - <ns0:MT_ReceiverFileStructure <namespace>"><Output><?xml version="1.0" encoding="ISO-8859-9"?><?xml-stylesheet type="text/xsl" href="<xsl>"?><Tarih_Date Tarih="11.09.2014" Date="09/11/2014>
       Thanks,
       Pavithra

    Thanks Praveen. It worked.
    However, the xml i have is an extract from a exchange rate URL and it has the reference to a xsl in it as below
    <?xml version="1.0" encoding="ISO-8859-9"?><?xml-stylesheet type="text/xsl" href="<ABC.xsl>"?>.
    So there is an error in sxmb_moni. Is it possible to remove this.

  • XSL to validate xml structure using XSD

    Hi,
    Can you please provide me a sample xsl that validates input XML against the given schema?
    I have been trying with the following, but I am getting an error in jdeveloper 11g.
    XML-23003: (Error) XPath 2.0 feature schema-element/schema-attribute not supported
    Process exited with exit code 1.
    <?xml version="1.0" encoding="windows-1252" ?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import-schema schema-location="po1.xsd"/>
    <xsl:output method="xml" version="1.0" indent="yes"/>
    <!-- Root template -->
    <xsl:template match="/">
    <xsl:if test="not(* instance of schema-element(authorising))">
    <xsl:message terminate="yes">
    Source document is not a validated Provisioning list
    </xsl:message>
    </xsl:if>
    <xsl:apply-templates/>
    </xsl:template>
    </xsl:stylesheet>
    Thanks
    923344

    Hi,
    Can you please provide me a sample xsl that validates input XML against the given schema?
    I have been trying with the following, but I am getting an error in jdeveloper 11g.
    XML-23003: (Error) XPath 2.0 feature schema-element/schema-attribute not supported
    Process exited with exit code 1.
    <?xml version="1.0" encoding="windows-1252" ?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import-schema schema-location="po1.xsd"/>
    <xsl:output method="xml" version="1.0" indent="yes"/>
    <!-- Root template -->
    <xsl:template match="/">
    <xsl:if test="not(* instance of schema-element(authorising))">
    <xsl:message terminate="yes">
    Source document is not a validated Provisioning list
    </xsl:message>
    </xsl:if>
    <xsl:apply-templates/>
    </xsl:template>
    </xsl:stylesheet>
    Thanks
    923344

  • Is there a way to get the actual XML string when using the JAXP SAX Parser?

    Hi All,
    I am using a JAXP SAX xml parser and am looking for a way to get the actual line of xml that is being parsed from within a content handler.
    Here's my scenario. Consider the following example xml document.
    <formCollection>
       <form name="myForm">
          <text/>
          <selection/>
       </form>
       <form name="anotherForm">
          <text/>
       </form>
    </formCollection>My hope is to validate the entire document and then insert an xml string containing each "form" element (and its sub-elements) into a map for later use. My thought was to create a String as each "form" element is being parsed (begining with the form's startElement event and concatenating until the form's endElement event is reached) and then inserting this string into the map. Is there a way to get the actual line of xml that is being parsed, rather than just the element name and attribute values?

    DrClap wrote:
    YouRang wrote:
    2. The first handler would validate the entire XML document, extract the "type" attribute from each <form> element, and place each <form> element and its sub-elements into the map of Strings, using the "type" attribute as the key. The second handler would take a <form> element and parse it into a Form object for the display. This option was the impetus for my question because it relies on the first handler being able to access the entire <form> element XML String and write it to a map.I don't see why you need the raw data from the XML document here. You should already be abstracting your data into Java classes in the first handler, instead of making the second handler do the parsing all over again.Correct, I am not referring to XForms. In this case, it happens that I am using the XML to generate an SWT ScrolledForm object and, thus, the XML element name happens to be named "form." However, the concept/design problem could apply to any type of object and the XML element could be appropriately renamed.
    My experience with XSLT is limited and I haven't done anything with it for several years. With that said, it seems that it is primarily used for generating web content, which wouldn't apply in this case because this is for a client-server application. I could be off base on this one -- if XSLT applies to much broader translations and would be more appropriate for generating Java objects than my current methodology, I could certainly look into it further.
    I apologize that option two didn't make more sense; it is difficult to explain. Yes, optimally the data should be abstracted into Java classes in the first handler. This is really an elaboration that I failed to specify when explaining option one. The problem is that the user can choose to create any number of "forms" of any type. For instance, let's say that from the File -> New menu there are options for seven different types of forms and each form is used to send completely different data. The user can select form1, select form1 again, select form4, and select form7 (or any other combination) and bring up tabs that display the different forms. The user can then enter data and submit each form separately. When the user selects File -> New -> FormX, a SWT ScrolledForm object that corresponds with FormX must be given to the display. Because SWT ScrolledForm objects do not allow a deep copy, I cannot simply read the XML <form> elements at initialization, parse them into ScrolledForm objects, and pass deep copies of the ScrolledForm objects to the display each time the user clicks File -> New -> FormX. The only simple way I see of getting a new copy of a ScrolledForm object is to reparse the appropriate XML <form> element in order to create one each time the user selects File -> New -> FormX. As such, one handler would need to read the entire XML document and parse the <form> elements into a map (or some other data structure) and another handler would need to parse individual <form> elements into SWT ScrolledForm objects. The first handler would be called at initialization and the second handler would be called each time a user clicked on File -> New -> FormX. Once again, this isn't exactly my favorite implementation... but seems the simplest given that there is no way to do a deep copy of an SWT ScrolledForm object. Hopefully that makes a little more sense. No worries if it doesn't -- I just figured I'd throw this out there and see if anyone had a better idea.

  • Problem in producing some xml strings

    Dear all,
    I got a problem in producing some xml string. I use the DocumentBuilderFactory and DocumentBuilder to build a xml document. Instead of saving to a file, I need to make it into a string then return it to the caller. I have tried to use the Transformer but the string returned contains the <?xml version=..../> line which I don't want it. What can I do?

    What you want to do is associate a stylesheet with the transformer instance you are using to place the DOM into string. The stylesheet with the appropriate instructions are get rid of the <?xml version=..>. You want to produce a stylesheet which has:
    <xsl:output omit-xml-declaration="yes"/>
    <xsl:template match="/">
    <xsl:copy-of select="node()"/>
    </xsl:template>
    <xsl:output> controls the serialisation of the xml document to the output source which in this case is a string. The <xsl:template> is required. It will copy the entire xml document to the output source. Without it the default templates are used, and the xml markup will not be included in the output source.
    Hope this helps.

  • Applying REGEX-pattern into XML File

    I have the following problem:
    I have an xml-file. let's say...
    <NODE><NODE1 attr1="a1" attr2="a2">
         <NAME> abc</NAME>
         <VERSION> 1.0</VERSION>
    </NODE1>
    <NODE2 attr1="a3" attr2="a4">
         <NAME> xyz</NAME>
         <VERSION> 3.1</VERSION>
    </NODE2></NODE>I need to know "HOW can I get the values of <NAME></NAME> and <VERSION></VERSION> without using DOM.
    Since my xml-file is pretty big and DOM will take much Memory, i want to avoid it.
    Can anybody suggest some "Regex pattern" so that i can apply it on the xml-file (after converting into String)
    Thanks in Advance

    That worked perfectly. I assumed ( insert comment here ) that the members of the Properties objects were Strings, and therefore followed the same rules where "\" characters are concerned.
    Thank you for pointing out the difference between the two objects, I am not sure how long it would have taken me to figure that out.
    Regards,
    John Gooch

  • Handling long XML strings in XSLT

    I am creating an XML string dynamically to feed to my XSLT processing servlet. In a prototype I did this by passing the XML as a string to a routing servlet that then calls HttpResponse.sendRedirect() with the name of the XSLT processing servlet and the XML string like this :
    redirectString = "/WardenConfig/servlet/XSLTServlet?xslPage=" + nextPage + "&xmlSourceString=" + XMLData ;
    where XMLData is the dynamically built XML and nextPage is an XSL stylesheet. Then I send use this to send it all to the servlet that processes the XSL and displays the result :
    response.sendRedirect( redirectString );
    The problem is that when I get a lot of data in the XML string this does not work. I think this might be because sendRedirect() uses the GET method but I am not sure. SO I had two questions :
    1) Is that the problem - the GET method, I mean ?
    2) What's a better way to do this ?
    thanks in advance !!

    Will do, Doctor. I appreciate your quick help ! Is that the way most people handle this ?
    By the way, if you can tell me how to award Duke Dollars, I would like to do that. For some reason I can't do it anymore .. used to be able to ... feel lame ...
    Thanks again.

  • Update xml string values.

    Hi,
    I'm on 11.2.0.2 and got table with nclob column which stores long xml string .
    {code}
    "<?xml version="1.0" encoding="UTF-8"?>
    <?fuego version="6.5.2" build="101272"?>
    <set>
    <configuration name="TEST Database" type="SQL" subtype="DDORACLE">
      <property name="jdbc.pool.idle_timeout" value="5"/>
      <property name="jdbc.pool.entry.max" value="10"/>
      <property name="oracle.dateEqualsTimestamp" value="false"/>
      <property name="jdbc.schema" value="user1"/>
      <property name="jdbc.host" value="hostname"/>
      <property name="user" value="user1"/>
      <property name="jdbc.port" value="1521"/>
      <property name="jdbc.pool.min" value="0"/>
      <property name="jdbc.pool.maxopencursors" value="50"/>
      <property name="oracle.sid" value="dbsid"/>
      <property name="password" value="user101"/>
      <property name="jdbc.xa" value="false"/>
      <property name="jdbc.pool.max" value="10"/>
    </configuration>
    <configuration name="TEST Database2" type="SQL" subtype="DDORACLE">
      <property name="jdbc.pool.idle_timeout" value="5"/>
      <property name="jdbc.pool.entry.max" value="10"/>
      <property name="oracle.dateEqualsTimestamp" value="false"/>
      <property name="jdbc.schema" value="user2"/>
      <property name="jdbc.host" value="hostname"/>
      <property name="user" value="user2"/>
      <property name="jdbc.port" value="1521"/>
      <property name="jdbc.pool.min" value="0"/>
      <property name="jdbc.pool.maxopencursors" value="50"/>
      <property name="oracle.sid" value="dbsid2"/>
      <property name="password" value="user201"/>
      <property name="jdbc.xa" value="false"/>
      <property name="jdbc.pool.max" value="10"/>
    </configuration>
    </set>
    {code}
    My goal is to update password value in such way that it equals to value from jdbc.schema value  <property name="jdbc.schema" value="user2"/>   so in this case user2 || '01'
    <property name="password" value="user201"/>   <-- that is my goal .
    Regards
    Greg

    Hi,
    You can find a few methods here : How To : Update XML nodes with values from the same document | Odie's Oracle Blog
    They're not all applicable to your version and settings though.
    Here's the first one applied to your case :
    declare
      v_xmldoc   xmltype;
    begin
      select xmlparse(document to_clob(t.xmldoc))
      into v_xmldoc
      from my_nclob_table t
      where t.id = 1;
      for r in (
        select idx, schema_name
        from my_nclob_table t
           , xmltable(
               '/set/configuration'
               passing v_xmldoc
               columns idx         for ordinality
                     , schema_name varchar2(30) path 'property[@name="jdbc.schema"]/@value'
      loop
        select updatexml(
                 v_xmldoc
               , '/set/configuration['||to_char(r.idx)||']/property[@name="password"]/@value'
               , r.schema_name || '01'
        into v_xmldoc
        from dual ;
      end loop;
      update my_nclob_table t
      set t.xmldoc = to_nclob(xmlserialize(document v_xmldoc indent))
      where t.id = 1;
    end;
    Here's another one, using DOM :
    declare
      doc   clob;
      p        dbms_xmlparser.Parser;
      domdoc   dbms_xmldom.DOMDocument;
      docnode  dbms_xmldom.DOMNode;
      conf_list      dbms_xmldom.DOMNodeList;
      conf_node      dbms_xmldom.DOMNode;
      password_node  dbms_xmldom.DOMNode;
      schema_name     varchar2(30);
      password_value  varchar2(256);
    begin
      select to_clob(xmldoc)
      into doc
      from my_nclob_table
      where id = 1 ;
      p := dbms_xmlparser.newParser;
      dbms_xmlparser.parseClob(p, doc);
      domdoc := dbms_xmlparser.getDocument(p);
      dbms_xmlparser.freeParser(p);
      docnode := dbms_xmldom.makeNode(domdoc);
      conf_list := dbms_xslprocessor.selectNodes(docnode, '/set/configuration');
      for i in 0 .. dbms_xmldom.getLength(conf_list) - 1 loop
        conf_node := dbms_xmldom.item(conf_list, i);
        dbms_xslprocessor.valueOf(conf_node, 'property[@name="jdbc.schema"]/@value', schema_name);
        password_node := dbms_xslprocessor.selectSingleNode(conf_node, 'property[@name="password"]/@value');
        dbms_xmldom.setNodeValue(password_node, schema_name || '01');
      end loop;
      dbms_xmldom.writeToClob(domdoc, doc);
      dbms_xmldom.freeDocument(domdoc);
      update my_nclob_table t
      set t.xmldoc = to_nclob(doc)
      where t.id = 1;
    end;
    Message was edited by: odie_63 - added DOM example

  • Generating XML String

    I may have missed something obvious but the SAX & DOM bits of
    the XML Parser don't seem to supply any way of getting from a
    set of parsed (or created) Document Java objects to a marked up
    XML string. Is this something we have to do ourselves by
    navigating through the node tree and adding the necessary
    markup? It seems generic enough to be provided by one of your
    APIs (such as the XSL bits?).
    Thanks,
    Dave
    null

    Thanks,
    I found the print method on the XMLDocument class which
    generates an encoded string from that XMLDocument. This is fine
    but what I had was a DocumentFragment reference returned from
    the XSLProcessor.
    I assume you have to get an XMLDocument from this
    DocumentFragment (since XMLDocument doesnt implement that
    interface) by creating an empty XMLDocument and then appending
    the DocumentFragment as a child element. You can then use the
    print method to get the XML string containing the styled XML.
    This seems to work ok. Is this the right way to go about it?
    Cheers,
    Dave
    Oracle XML Team wrote:
    : In oracle.xml.parser.NodeFactory you will find a
    createDocument
    : method which will create the document node to get your XML
    : document starter. This method was omitted in the DOM Level 1
    : Req but has been added for Level 2. We have implemented it in
    : both our v1 and v2 parsers.
    : Oracle XML Team
    : http://technet.oracle.com
    : Oracle Technology Network
    : Dave Barton (guest) wrote:
    : : I may have missed something obvious but the SAX & DOM bits
    of
    : : the XML Parser don't seem to supply any way of getting from
    a
    : : set of parsed (or created) Document Java objects to a marked
    : up
    : : XML string. Is this something we have to do ourselves by
    : : navigating through the node tree and adding the necessary
    : : markup? It seems generic enough to be provided by one of
    your
    : : APIs (such as the XSL bits?).
    : : Thanks,
    : : Dave
    null

  • Performance problem submitting big XML string parameter to the web service

    We deployed a web service on the OC4J via oracle.j2ee.ws.StatelessJavaRpcWebService . This web service takes one string as a parameter. The string contains XML. Evrything works great UNLESS input XML string reaches 5Mb in size. When it happens OC4J does something with it for about 10 minutes (yes, minutes) before it calls the web service method. At this time java.exe consumes 100% of CPU.
    WE tried to increase JVM heap size, stack size, etc, - no effect.
    Please, help!
    Thank you in advance,
    Vlad.

    Hi Sheldon,
    What i feel is that it's not been handled in your webservice if the parameter is null or "" <blank> space
    i just you to take care in webservice that if the parameter is null or "" pass the parameter null to the stored proc
    Regards
    Pavan

Maybe you are looking for