Use DOM as an argument of  XSLT document() function

I have in memory several DOM documents. I have not stored in file system the XML files that are represented by these DOMs. I want to process with a stylesheet
all of these DOMs (as DOMSource's) using document() function from the stylesheet. How can I refer to the secondary DOMs from document function if I haven't the files?
F.e.
<xsl:value-of select="document('file.xml')/.../..."/> file.xml only exists loaded in memory as DOM.
Can anybody help me?? Thanks

Thank you DrClap but I'm not sure about the use of URIResolver:
if my xslt:
<xsl:value-of select="document('file1.xml')\...\..."/>
<xsl:value-of select="document('file2.xml')\...\..."/>
I must define my own class that implements URIResolver and write my own resolve method, isn't it?
class Resuelve implements URIResolver{
     private Document doc1;
     private Document doc2;
     public Resuelve(Document doc1, Document doc2){
          this.doc1 = doc1;
          this.doc2 = doc2;
     public Source resolve(String href, String base){
          if(base.equalsIgnoreCase("file1.xml")){
               Source s1 = new DOMSource(doc1);
               return s1;
          else if(base.equalsIgnoreCase("file2.xml")){
               Source s2 = new DOMSource(doc2);
               return s2;
          else{
               return null;
I suppose that XSLT processor use automatically resolve method. I don't understand the href parameter...
Is this class correct? if not, can you show me an example please?
Thank you very much

Similar Messages

  • Looking for example - abap xslt - that uses xslt document() function

    Hello,
    I'm looking for an example that shows the use of abap xslt with the xslt document() function.  Using the xslt document() function seems like a straightforward way to use xslt to create a result xml document by processing the content of two or more
    source documents.  For example, if source document A.xml and aux.xml are available in  memory as xstringand using stylesheet ztransformwhat would be the argument for the document() function to associate aux.xml.  Thanks for any insight.
    Regards,
    jb10809

    Hi,
    Sorry, perhaps I should have been clearer! The function that I picked just to test what you need to do just happened to return a string that contains SPAN tags with style attributes. The actual function code is:
    create or replace FUNCTION out_string_fn
       RETURN VARCHAR2
    IS
       CURSOR emp_cur
       IS
          SELECT ename
            FROM emp;
       v_string   VARCHAR2 (4000);
    BEGIN
       v_string := ' ';
       FOR c IN emp_cur
       LOOP
          v_string :=
                v_string
             || '&lt;SPAN style="font-weight:bold;color:green"&gt;'
             || c.ename
             || '&lt;/SPAN&gt;'
             || ', &lt;/br&gt;&lt;/br&gt;';
       END LOOP;
       RETURN v_string;
    END;And this returned a naff list in green (see [http://apex.oracle.com/pls/otn/f?p=55041:57] and click the Test button) - but it does show that you can style the validation error messages
    Andy

  • XSLT document() function in PL/SQL XDK

    I'm using the PL/SQL XDK (9.2.0.2.0) to do XSLT transformations but having
    no success using the XSLT document() function.
    I just get the error
    ORA-20100: Error occurred while processing: XSL-1021: (Error) Error parsing
    external document: 'wrongmachine.mycompany.com'.
    Can the document function access an external xml file using http from pl/sql?
    eg. http://amachine.mycompany.com/xmldocs/myxml.xml
    I've tried setting the ref parameter of the newStylesheet function, assuming
    this sets up the base uri for the stylesheet
    xslss := xslProcessor.newStylesheet
    (xmldoc => xsl_doc,
    ref => 'http://amachine.mycompany.com/xmldocs');
    I've also used the setBaseDir on both the DOMDocument and the stylesheet
    xmlparser.setBaseDir(p => xsl_parser,
    dir => 'http://amachine.mycompany.com/xmldocs');
    I've tested the XSL stylesheet in Saxon and it works fine.
    Other XSL transformations also work fine using the Oracle XDK but none that use
    document()
    'wrongmachine.mycompany.com' is not even the machine the code is executing on!?
    Is this set up in an installation script?
    Any ideas/examples on how document() can be used in the pl/sql XDK?
    Thanks
    John Holder

    BTW: following this link
    xsl:include within XSL stylesheet stored in XMLType column
    i've encountered that this theme has been asked but none from Oracle staff has answered on it yet ;(((((((

  • XSLT document function - bug?

    I have an XSLT stylesheet which loads several XML documents, by using the XSLT document() function.
    The XSLT document() function works fine using Saxon processor and Firefox. Also it works fine in Safari 3 when the XSLT stylesheet is processed as a stylesheet referenced from an XML-file.
    But, when processing the XSLT stylesheet from Javascript, in Safari 3, using xsltProcessor.transformToDocument() the document() function does not load the files. It can be added, that I am running everything from the local harddrive.
    Anyone has similar experience or some workaround?
    There is a similar post http://discussions.apple.com/thread.jspa?threadID=1559485&tstart=1 about Safari-Windows, but no resolution to the problem.
    Message was edited by: Tomas Jonsson
    Message was edited by: Tomas Jonsson

    I have now made an example to demonstrate this bug. Firefox 3 will do the right thing, Safari 3 and 4 both have the same problem.
    http://www.tomasjonsson.eu/docbugtest/docbugtest.html

  • XSLT document() function

    I am using the Oracle XML parser, and I am finding that some funny things are happening when I try to use the document(object, node-set?) function, as defined in the XSLT specification. For some reason, my xmlns path is being prepended to any file path I use in the "object" argument, so I can't access any local files:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"/>
    <xsl:value-of select="document('local_file')"/>
    ... results in the following error message:
    oracle.xml.parser.v2.XSLException: XSL-1021: Error parsing external document: 'http://www.w3.org/XSL/Transform/local_file';
    Furthermore, if I try to use the "node-set" (2nd) argument, I get invalid expression errors.
    Any suggestions?
    Thanx, Kat.

    Hi,
    There could be a problem with the way the XSLStylesheet is being created. If you are using the command line version, it could be a
    problem in the parser. If you are using programmatic construction of the XSLStylesheet, be careful that that the second argument 'URL ref' is used to get absolute paths from relative paths. Check what you are setting this second arg
    to. Let us know if you experience additional problems.
    Thanks,
    Oracle XML Team
    null

  • XSLT document() function not working properly

    I have this XSLT:
    <xsl:copy-of select="document($file1)/employee/address/*"/>
    I have this java which is setting the parameter for $file1
    transformer.setParameter("file1",file.getAbsolutePath());I printed out the value of $file1 in the XSLT style sheet using:
    <xsl:message><xsl:value-of select="$file1"/></xsl:message>
    The Path it prints out is the correct path, let say its c:\myfile\file1.xml
    When it reaches the doument($file1) function, it seems that the path is getting changed.
    To give you an example, if $file1 = "c:\myfile\file1.xml" and my XSLT file is located at c:\xsl\myXSl.xsl then the path that document() gets is:
    c:\C:\xsl\myfile\file1.xml
    This causes the following error to occur:
    (The filename, directory name, or volume label syntax is incorrect)
    Why is document() inserting the path where the XSL file which it is in into the path of the file I'm trying to open? I am using the Xalan API to transform this XML.
    Have anyone seen anything like this before?
    Thanks
    Al

    When I looked up some Internet pages that described the document() function, they all said it required a URI as its parameter. A Windows file path is not a URI. However it's possible to get a URI from a File object, so you might want to try that.

  • XSLT document function issue

    I have XSL transformation using document() function to combine xml docs, using Oracle 10.2.0.2.
    <xsl:for-each select="document('/export/home/myunixdirectory/Products.xml')/PRODUCTS">
    When I run DBMS_XSLPROCESSOR.processXSL(proc, ss, document_in); I get error
    ==============
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    ==============
    Products.xml is valid, tried it with no unix directory specified, etc., no luck. Also have commented out section related to document function and code works, so it is related to this document processing in the Oracle XSL processor. The transformation works in XMLSPY (pointing to files on local drive).
    Any ideas on how to get this to work?

    Here's more info in case anyone wants take a crack at guessing what's wrong. I've tried a bunch of different methods for document() function, at this point I am nearly convinced it is not supported by the Oracle XSL processor.
    Products.xml...
    <?xml version="1.0" encoding="UTF-8"?>
    <PRODUCTS>
         <PRODUCT>
              <BRAND_CODE>11111</BRAND_CODE>
              <BRAND_NAME>SOMETHING HERE</BRAND_NAME>
              <GRADE>P</GRADE>
         </PRODUCT>
    </PRODUCTS>
    XSL file (simplified)…in same directory as Products.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
         <xsl:variable name="geterrorwhenrun" select="document('Products.xml')"/>
         <xsl:template match="/REGION">
              <REGION>
                   <xsl:attribute name="xsi:noNamespaceSchemaLocation">any.xsd</xsl:attribute>
              </REGION>
         </xsl:template>
    </xsl:stylesheet>
    Error I get...
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    PL/SQL Code...
    -- parse xsl file
    DBMS_XMLPARSER.parse(p, xslfile);
    -- get document
    xsldoc := DBMS_XMLPARSER.getDocument(p);
    -- make stylesheet
    ss := DBMS_XSLPROCESSOR.newStylesheet(xsldoc, xslfile);
    proc := DBMS_XSLPROCESSOR.newProcessor;
    DBMS_XSLPROCESSOR.showWarnings(proc, true);
    docfrag := DBMS_XSLPROCESSOR.processXSL(proc, ss, document_in);
    -- GET ERROR on line above, however if I comment out the geterrorwhenrun variable line, transform works

  • Secondary XML source via document() function

    Has anyone used the XSLT document function in an XSL-FO template where the file is an URL. We are trying to do this to get extra information for the PO output in an EBS installation without horrible customisations
    eg
    <xsl:text>Person : <xsl:value-of select="document('http://dbsdev11.uk.baa.com:8031/OA_HTML/test.xml')/xxpo:PO_DATA/xxpo:PERSON_ID"/></xsl:text>
    where test.xml is:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xxpo:PO_DATA xmlns:xxpo="http://uk.baa.com/oracle/apps/po/info">
    <xxpo:PERSON_ID>120</xxpo:PERSON_ID>
    <xxpo:SERVER_PORT>8031</xxpo:SERVER_PORT>
    </xxpo:PO_DATA>
    and the URL http://dbsdev11.uk.baa.com:8031/OA_HTML/test.xml resolves quite happily when pasted into a browser.
    But nothing comes back when previewing the template in EBS. PDF is produced but Person value is not populated.
    Is the document function supported??
    Rgds
    James M

    Hi Jame
    Document() is supported but what you are trying to do with it is not, i.e.
    document('http://dbsdev11.uk.baa.com:8031/OA_HTML/test.xml')/xxpo:PO_DATA/xxpo:PERSON_ID"/
    will not work. You need to load the doc to a variable and then reference the PERSON_ID element.
    Something like:
    Variable Declaration
    ==================
    <xsl:variable name="news" select="document('http://rss.news.yahoo.com/rss/topstories')"/>
    Value
    ========================
    <?$news/rss/channel/title?>
    regards
    Tim

  • How to use xsl document() function with LiveCycle XSLT processor

    Hello,
    I would like to use LiveCycle XSLT processor to merge xml documents by using the xsl document() function.
    However, I have not, yet, found  clear reference information on the specifics of how to accomplish in LC. For instance if you have
    a transformation that does merging using a standalone xml editor (such as Oxygen), than what is required to accomplish the same
    using the LiveCycle XSLT service.  How do you specify the URI of the XML document that is specified as an input in the xsl document() function. Your insight is appreciated.   Regards

    Hello Steve,
    I checked the reference that you cited (XSLT Transformation).   The reference omits discussing how to use xlst document() function within a stylesheet.  I think that probably means that feature of xslt technology is not directly available through LiveCycle.  When I find a workaround, I'll post an update...for the user community that might encounter the same issue.  Thank you for your response and insight.  Regards, jb1809

  • Use document() function in xslt

    Hi I want to use the xslt function document() to import a data file into the transformation.
    However I don't seem to be able to import the xml file onto the osb. can this be done ?
    Basically can you use the document() function?
    I've tried googling and searching the docs but i think i'm missing something basic :-)
    Thanks in advance

    Not an answer to the particular point but i've got round the issue by adding a stage which inserts the data xml into the xml document being transformed.
    I then supress the data injected from being copied to the output tree and use a variable which references the data nodes rather than a variable referencing
    an external doc variable name="myvar" select="//injecteddatanode" /> rather than <variable name="myvar" select="document("path/doc.xml")
    The question still stands though : how do you import an xml doc which can then be used by the document function in a transform

  • Use DOM to get the element value of XML document?

    I can not to use the method getNodeValue to get the element value of XML document. How can I do for it?
    For example, for element
    <address>125 Smith Avenue</address>
    how to get the value "125 Smith Avenue" by using DOM?
    Thanks

    Thanks for all of you.
    The code indicates that I need to get the node by tag name. If I do not know the distribution of the elements and want to traverse all nodes. If the node contains value, I retrieve the value. How to implement the general case.
    For example, my XML file represent a directory hierarchy and looks like
    <root>
    <usr>
    <user>user1
    <file>file1</file>
    <file>file2</file>
    </user>
    <user>user2
    <file>file1</file>
    <file>file2</file>
    <file>file3</file>
    <file>file4</file>
    </user>
    </usr>
    </root>

  • Using DOM

    Hi everyone,
    I was wondering if someone could give me a hand with the following.
    I am planning to create a simple search engine to search for products for a computer parts retailer. The list of products is stored in an XML repository , and all queries to this repository are sent as XML documents.
    The search engine web page will display a single text input field, into which a user can enter a keyword to search for
    I am using DOM to convert the Html search query to an XML document.
    Here is my DOM code so far.
    <%@page import="java.io.*"%>
    <%@page import="javax.xml.parsers.*"%>
    <%@page import="org.w3c.dom.*"%>
    <%@page import="org.apache.xml.serialize.*"%>
    <%!
    String 
    search,textfield;
    %>
    <%
    // Retrieve the Search query
    search = request.getParameter("search");
    textfield = request.getParameter("textField");
    // Create a new DOM factory, and from that a new DOM builder object
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();// Note that we are creating a new (empty) document
    Document document = builder.newDocument();
    // The root element of our document wil be <query>
    // It gets stored as the child node of the whole document (it is the root)
    rootElement = document.createElement("query");
    document.appendChild(rootElement);
    // Create an <searchterm> element , place underneath <query>
    Element searchtermElement = document.createElement("searchterm");
    searchtermElement.appendChild(document.createTextNode(searchterm));
    rootElement.appendChild(searchtermElem
    I am just wondering if my DOM code looks correct so far?

    A further cast didn't help either. For a change I have abandonded the JAXP approach and instead have built an example found at
    http://otn.oracle.com/pub/listings/vohra_xmlschema_l4.html
    that shows how to validate against a schema.
    I have changed the method to return the validated document and have then tried to apply some of the D0M validation methods supposed to return a NameList but I still always get null.
    I have posted the example Java program at
    http://home.arcor.de/martin.honnen/java/xml/Test20040308.java.txt
    and run it against the example schema and XML files at http://home.arcor.de/martin.honnen/java/xml/test20040307Xsd.xml http://home.arcor.de/martin.honnen/java/xml/test20040307.xml
    While the parsing works and the XML is judged valid according to the schema attempts to use the DOM validation methods to return a NameList fail to return one.
    Does anyone have an example using any DOM Level 3 validation interfaces/methods successfully?

  • Parsing xml using DOM parser in java

    hi there!!!
    i don have much idea about parsing xml.. i have an xml file which consists of details regarding indentation and spacing standards of C lang.. i need to read the file using DOM parser in java n store each of the attributes n elements in some data structure in java..
    need help as soon as possible!!!

    DOM is the easiest way to parse XML document, google for JDOM example it is very easy to implement.
    you need to know what is attribute, what is text content and what is Value in XML then easily you can parse your document with dom (watch for space[text#] in your XML document when you parse it).
    you get root node then nodelist of childs for root then go further inside, it is easy believe me.

  • Using xsl document function in transform xsl

    I'm trying to use an external xml document in an xsl transform that's used in a Transform activity in an 11g BPEL process:
    <xsl:variable name="plants" select="document('plantTransposeLookup.xml')/plants"/>
    I need to load up the document to use it in a lookup to get replacement values for a key.
    This works fine in JDev, but not when I deploy it to the server.
    The error I get when I run it is:
    The XPath expression failed to execute; the reason was: javax.xml.transform.TransformerException: XML-22021: (Error) Error parsing external document: 'no protocol: plantTransposeLookup.xml'.. Check the detailed root cause described in the exception message text and verify that the XPath query is correct.
    I've also gotten:
    The XPath expression failed to execute; the reason was: javax.xml.transform.TransformerException: XML-22021: (Error) Error parsing external document: 'Unsupported feature: 'document(''), when stylesheet built using InputStream, Reader'.
    I've also tried using the ora:doc function:
    <xsl:variable name="plants" select="ora:doc('plantTransposeLookup.xml', 'plants')"/>
    ......but this doesn't work in JDev and is also erroring off on the server with:
    The XPath expression failed to execute; the reason was: javax.xml.transform.TransformerException: XML-22016: (Error) Extension function namespace should start with 'http://www.oracle.com/XSL/Transform/java/'.. Check the detailed root cause described in the exception message text and verify that the XPath query is correct.
    Does anyone know how to actually import an xml doc into a mapper??? I must be doing something stupid.
    Thanks for any help.

    In OSB, document() function needs absolute path of the XML file. So if you want to access the XML document for lookup, you need to put the XML file on the server itself and use the path of the XML file.
    Although this is not a correct approach for managing lookups in OSB. The resource of XML Document type are not to be used for such use cases. What you can do is create a XQuery which can server as DVM.
    Here is an example on how to use DVMs in OSB:
    https://blogs.oracle.com/christomkins/entry/domain_value_maps_in_oracle_se
    If you dont want to use XQuery and want to rely only on XSLT, then within the same XSLT document create a separate template which can store all the lookup data.

  • How to ignore empty text element while using DOM to parse xml??

    hi everyone,
    i am using DOM to parse an xml file. But i dont know how to cinfig the DocumentBuilderFactory to ignore empty text elements.
    For example, i have an xml file like this:
    <?xml version="1.0" encoding="UTF-8" ?>
    <root>
        <child>Tom</child>
        <child>Jerry</child>
    </root>I used the following codes to parse:
    String fname = "Tom-and-Jerry.xml";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setIgnoringElementContentWhitespace(true);
    factory.setIgnoringComments(true);
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    // Generate a DOM tree from the DOM builder.
    org.w3c.dom.Document dom = builder.parse(new File(fname));
    org.w3c.dom.NodeList list = dom.getChildNodes();
    for (int i=0; i<list.getLength(); i++) {
        System.out.println("Child No."+i);
        System.out.println("NodeName="+list.item(i).getNodeName());
        System.out.println("NodeType="+getType(list.item(i).getNodeType()));
        System.out.println("NodeValue="+list.item(i).getNodeValue());
        System.out.println();
    }The result is not exactly what i want ---- there are 5 children in list!! The 1st, 3rd and 5th are #text and their values are all empty. Only the 2nd and the 4th are the child that i expect.
    It is really troublesome to get all these silly empty texts as sub elements. I tried to get rid of them, but i failed. I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.
    Anyone can help me? thanks.
    Heavy ZHENG

    I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.That only does something if the XML has a DTD that enables it to know what whitespace can be ignored and what is significant. The API documentation for the method refers you to this document:
    http://www.w3.org/TR/REC-xml#sec-white-space

Maybe you are looking for

  • How do you know what version methods became available ?

    A reply to another one of my posts informed me that String.replaceAll did not become available until version 1.4. How could I find out what version methods became available? I think I'm experiencing a similar situation with String.ValueOf. Thanks in

  • Trying to build pacman ...

    ... but makepkg is struggling to download the source, even though I can easily do it via web browser. So, after extrating the source, and realising that I can now do: makepkg -e I then get: ==> Making package: pacman 4.2.0-6 (Sun 1 Feb 11:59:34 GMT 2

  • Autoconfig errors

    HI, My Apps-11.5.10.5 RDBMS 9i clonning was succesfull ..... Skipping the starting of services INFO : Rapid Clone completed successfully , but the AutoConfig run recorded some errors. Please review the AutoConfig section in the logfile. If required,

  • Need some help with multi dimensional arrays plz

    Hello, Lets say I have a three-dim array, call it pyList. This array goes from pyList[0][0][0] to pyList[5][5][5] (216 values). Now, I also have a two-dim array, call it V, which goes from V[0][0] to V[35][5]. What I would like to do is assign V[0][0

  • Help me? I can't power off the computer on archlinux0.8??

    When i use the command 'halt -p', it only just power off the harddisk but not shut off the computer power! Kernel version: normal kernel2.6.20 I see the kernel config file, the apm default build in the kernel? when i start the apmd service, but faile