Target XML attribute with XSLT

Hello,<br />I have an xml file which looks like this:<br /><br /><PRODUCTS><br /><PRODUCT><br /><IMAGE href="file://./0001.tif"></IMAGE><br /></PRODUCT><br /><PRODUCT><br /><PRODUCTS><br /><br />Is there a way to target the href attribute of the PRODUCT element with XSLT?<br /><br />Thanks

hi marco,
> Thank you gregor, I'll take a look to this reference; I'm total newby to
> XSLT, so any suggestions would be surely fine.. another question: do you
> think it's better to work with XSLT or XmlRules?
there is no short answer on this. it depends on your documents/data you
want to process, what to achieve and you're knowledge in scripting vs.
xslt. i use xmlRules for styling my documents, xslt for data transformation.
in general you've got more control, especially over the rendered
document, using xmlRules. if you want to process layout rules/guidelines
in dependency of the actual document you have to render it first.
complex data transformation and composition is better with xslt outside
of indesign. i prefer to prepare my data (select relevant data,
numbering, ...) with xslt.
cheers,
gregor

Similar Messages

  • Mapping of XML attributes with XML elements in Mediator Transformations

    Hi,
    The soure XML look like as below in the source directory of file adapter/read:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!-- Edited by Oracle JDeveloper 11.1.1.1.3®
    -->
    <CATALOG>
    <PLANT COMMON="Bloodroot" BOTANICAL="Sanguinaria canadensis">
    <ZONE>4</ZONE>
    <LIGHT>Mostly Shady</LIGHT>
    <PRICE>$2.44</PRICE>
    <AVAILABILITY>031599</AVAILABILITY>
    </PLANT>
    <PLANT COMMON="Columbine" BOTANICAL="Aquilegia canadensis">
    <ZONE>3</ZONE>
    <LIGHT>Mostly Shady</LIGHT>
    <PRICE>$9.37</PRICE>
    <AVAILABILITY>030699</AVAILABILITY>
    </PLANT>
    <PLANT COMMON="Marsh Marigold" BOTANICAL="Caltha palustris">
    <ZONE>4</ZONE>
    <LIGHT>Mostly Sunny</LIGHT>
    <PRICE>$6.81</PRICE>
    <AVAILABILITY>051799</AVAILABILITY>
    </PLANT>
    </CATALOG>
    The target XML will be as below in the target directory of file adapter/write.:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!-- Edited by Oracle JDeveloper 11.1.1.1.3®
    -->
    <CATALOG>
    <PLANT>
    <COMMON>Bloodroot</COMMON>
    <BOTANICAL>Sanguinaria canadensis</BOTANICAL>
    </PLANT>
    <PLANT>
    <COMMON>Columbine</COMMON>
    <BOTANICAL>Aquilegia canadensis</BOTANICAL>
    </PLANT>
    <PLANT><COMMON>Marsh Marigold</COMMON>
    <BOTANICAL>Caltha palustris</BOTANICAL>
    </PLANT>
    </CATALOG>
    So, I need to map attributes(COMMON and BOTANICAL) of XML data in the source with common and botanical elements of the XML in the target. How should I map attributes with elements in the XSL editor of the Mediator Transformation.
    Thanks,
    Arnab

    I will test it.
    I sale myself ONLY half CNY!

  • Transforming XML Data with XSLT in a servlet

    Trying to transform XML data using XSLT. The following code works fine outside of a servlet. But in a servlet it gives the following error :
    * Transformer Factory error
    javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Namespace not supported by SAXParser
    javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Namespace not supported by SAXParser
         at org.apache.xml.utils.DefaultErrorHandler.fatalError(DefaultErrorHandler.java:257)
         at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:813)
         at TransformationApp.XSLTTransformServlet.MyTransform(XSLTTransformServlet.java:79)
         at TransformationApp.XSLTTransformServlet.doGet(XSLTTransformServlet.java:39)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
         at org.apache.tomcat.core.Handler.service(Handler.java:287)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
         at java.lang.Thread.run(Thread.java:484)
    Several articles hinted at setting the factory namespace attribute to TRUE. I have tried that but same results. Here is the code :
    static Document document;
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    //factory.setNamespaceAware(true);
    //factory.setValidating(true);
    try {
    File stylesheet = new File(argv[0]);
    File datafile = new File(argv[1]);
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse(datafile);
    // Use a Transformer for output
    TransformerFactory tFactory =
    TransformerFactory.newInstance();
    StreamSource stylesource = new StreamSource(stylesheet);
    Transformer transformer = tFactory.newTransformer(stylesource);
    DOMSource source = new DOMSource(document);
    StreamResult result = new StreamResult(System.out);
    transformer.transform(source, result);
    } catch (TransformerConfigurationException tce) {
    // Error generated by the parser
    System.out.println ("\n** Transformer Factory error");
    System.out.println(" " + tce.getMessage() );
    // Use the contained exception, if any
    Throwable x = tce;
    if (tce.getException() != null)
    x = tce.getException();
    x.printStackTrace();
    } catch (TransformerException te) {
    // Error generated by the parser
    System.out.println ("\n** Transformation error");
    System.out.println(" " + te.getMessage() );
    // Use the contained exception, if any
    Throwable x = te;
    if (te.getException() != null)
    x = te.getException();
    x.printStackTrace();
    } catch (SAXException sxe) {
    // Error generated by this application
    // (or a parser-initialization error)
    Exception x = sxe;
    if (sxe.getException() != null)
    x = sxe.getException();
    x.printStackTrace();
    } catch (ParserConfigurationException pce) {
    // Parser with specified options can't be built
    pce.printStackTrace();
    } catch (IOException ioe) {
    // I/O error
    ioe.printStackTrace();
    Any help would be greatly appreciated.

    I don't know that this is true, but i think the problem is the classpath.
    The runtime has his own parser. This parser is befor your xalan.lib in the classpath and the
    parser from the runntime don't support namespace.
    Try Tomcat 4.
    Regard Dietmar

  • Xml Attributes with ADG

    Hi all,
    i'm new to flex.I have a problem regarding XML
    attributes."How to get the XML attribute value from the xml file to
    Flex application using HTTPService".I tried but it is coming only
    one attribute value.
    First i have to get the attribute values from the XML file
    and display in AdvancedDataGrid with tree structure.
    Here i will send my XML file and MXML file...
    Can u see and check my code............plzzz
    XML file................
    <?xml version="1.0" encoding="UTF-8"?>
    <todolist>
    <folder state="" label="Today todo list" isBranch="true"
    >
    <folder cat="Travel" state="High" duedate="3/09/2008"
    isBranch="false" label="book tickets" />
    <folder cat="Social" state="Low" duedate="4/09/2008"
    isBranch="false" label="Meeting at 7pm" />
    <folder state="" isBranch="true" label="Home " >
    <folder cat="Home" state="High" duedate="3/09/2008"
    isBranch="false" label="Pay power bill" />
    <folder cat="Home" state="High" duedate="3/09/2008"
    isBranch="false" label="Pay rent" />
    <folder cat="Home" state="Low" duedate="3/09/2008"
    isBranch="false" label="Call parents" />
    <folder cat="Home" state="Low" duedate="3/09/2008"
    isBranch="false" label="Attend John birthday party" />
    <folder cat="Home" state="Medium" duedate="3/09/2008"
    isBranch="false" label="Special Updates" />
    <folder cat="Home" state="high" isBranch="false"
    label="get Dr. appointment" />
    </folder>
    <folder state="" isBranch="true" label="Office " >
    <folder cat="Off" state="High" isBranch="false"
    label="Meeting at 5pm" />
    <folder cat="Off" state="Low" isBranch="false"
    label="Complete document and send to client" />
    <folder cat="Off" state="Low" isBranch="false"
    label="Interviews and Transcripts" />
    <folder cat="Off" state="High" isBranch="false"
    label="Set Deployment machine" />
    <folder cat="Off" state="High" isBranch="false"
    label="send status reports" />
    </folder>
    </folder>
    </todolist>
    MXML file............
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute"
    initialize="adgService.send()">
    <mx:HTTPService id="adgService" url="adg.xml"/>
    <mx:AdvancedDataGrid
    dataProvider="{adgService.lastResult.todolist.folder}">
    <mx:columns>
    <mx:AdvancedDataGridColumn headerText="Name"
    dataField="label"/>
    <mx:AdvancedDataGridColumn headerText="Age"
    dataField="state"/>
    </mx:columns>
    </mx:AdvancedDataGrid>
    </mx:Application>
    Thnaks & Regards
    edeewan

    "edeewan" <[email protected]> wrote in
    message
    news:[email protected]...
    > Hi all,
    > i'm new to flex.I have a problem regarding XML
    attributes."How to
    > get
    > the XML attribute value from the xml file to Flex
    application using
    > HTTPService".I tried but it is coming only one attribute
    value.
    >
    > First i have to get the attribute values from the XML
    file and display in
    > AdvancedDataGrid with tree structure.
    > Here i will send my XML file and MXML file...
    > Can u see and check my code............plzzz
    >
    > XML file................
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <todolist>
    > <folder state="" label="Today todo list"
    isBranch="true" >
    >
    > <folder cat="Travel" state="High" duedate="3/09/2008"
    isBranch="false"
    > label="book tickets" />
    > <folder cat="Social" state="Low" duedate="4/09/2008"
    isBranch="false"
    > label="Meeting at 7pm" />
    >
    > <folder state="" isBranch="true" label="Home " >
    >
    > <folder cat="Home" state="High" duedate="3/09/2008"
    isBranch="false"
    > label="Pay power bill" />
    > <folder cat="Home" state="High" duedate="3/09/2008"
    isBranch="false"
    > label="Pay rent" />
    > <folder cat="Home" state="Low" duedate="3/09/2008"
    isBranch="false"
    > label="Call parents" />
    > <folder cat="Home" state="Low" duedate="3/09/2008"
    isBranch="false"
    > label="Attend John birthday party" />
    > <folder cat="Home" state="Medium" duedate="3/09/2008"
    > isBranch="false"
    > label="Special Updates" />
    > <folder cat="Home" state="high" isBranch="false"
    label="get Dr.
    > appointment" />
    >
    > </folder>
    >
    > <folder state="" isBranch="true" label="Office " >
    >
    > <folder cat="Off" state="High" isBranch="false"
    label="Meeting
    > at
    > 5pm" />
    > <folder cat="Off" state="Low" isBranch="false"
    label="Complete
    > document and send to client" />
    > <folder cat="Off" state="Low" isBranch="false"
    > label="Interviews
    > and Transcripts" />
    > <folder cat="Off" state="High" isBranch="false"
    label="Set
    > Deployment
    > machine" />
    > <folder cat="Off" state="High" isBranch="false"
    label="send status
    > reports" />
    >
    > </folder>
    >
    > </folder>
    > </todolist>
    >
    >
    > MXML file............
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    > layout="absolute"
    > initialize="adgService.send()">
    >
    > <mx:HTTPService id="adgService" url="adg.xml"/>
    > <mx:AdvancedDataGrid
    >
    dataProvider="{adgService.lastResult.todolist.folder}">
    > <mx:columns>
    > <mx:AdvancedDataGridColumn headerText="Name"
    dataField="label"/>
    > <mx:AdvancedDataGridColumn headerText="Age"
    dataField="state"/>
    > </mx:columns>
    > </mx:AdvancedDataGrid>
    >
    > </mx:Application>
    >
    > Thnaks & Regards
    > edeewan
    Try
    <mx:AdvancedDataGrid
    dataProvider="{adgService.lastResult.folder}">

  • XML attribute 'with' reserved?

    While working on a XMPP implementation I'm noticing the attribute 'with' keeps throwing errors when trying to access it to set or get the data from it. Is that a reserved word or something? Sort of makes this difficult considering 'with' is used heavily in the spec..
    var xml:XML = <rootNode>
              <item with="test" without="rest">cool</item>
    </rootNode>;
    trace(xml.item.@without); // no problem
    //trace(xml.item.@with); // uncomment and you'll get error "Syntax error: expecting identifier before with."

    It can be how you access it when considering reserved words. Try trace(xml.item.attribute("with")); or trace(xml.item.@["with"]); 

  • Recursively Merging 2 XML files with XSLT

    Hi there, I'm having a problem with merging a couple of XML files. I've found a few examples of merging on-line but none that really help.
    Basically I have an XML file which is written out by my Java program that looks something like this:
    <alldata>
       <data val="xx">
          <data val="yy">
             <data val="ss"></data>
          </data>
       <data val="gg"></data>
    </alldata>The number of children and siblings can change by the way.
    Therefore in the XSLT document I'm displaying the data recursively, i.e.
    <tr><td><xsl:value-of select="@val"/></td></tr>
    <xsl:for-each select="*">
       <xsl:call-template name="itself"></xsl:call-template>
    </xsl:for-each>This all works fine, but I now need to do a side by side comparison with another XML document that has exactly the same structure, but could have different values. I'm not sure how to do this, perhaps using the same recursive code and using a sort of pointer to where you are in the 2nd XML file (see below), but I've no idea how to go about this?
    <tr><td><xsl:value-of select="@val"/></td>
           <td><xsl:value-of select="<2nd documents @val>"/></td>
    </tr>
    <xsl:for-each select="*">
       <xsl:call-template name="itself"></xsl:call-template>
    </xsl:for-each>Output:
    xx    xy
    yy    yy
    ss   ss
    gg   hhDoes anybody have any suggestions or help on how to achieve this?
    Cheers
    Dan

    I posted the same question on the xsl-list message list and got a working solution - here it is in case anyone else has the same problem:
    <xsl:variable name="a" select="document('doc1.xml')//data"/>
    <xsl:variable name="b" select="document('doc2.xml')//data"/>
    <xsl:template match="/">
         <table>
           <xsl:for-each select="$a">
             <xsl:variable name="p" select="position()"/>
             <tr>
               <td><xsl:value-of select="@val"/></td>
               <td><xsl:value-of select="$b[$p]/@val"/></td>
             </tr>
           </xsl:for-each>
         </table>
    </xsl:template>Cheers
    Dan

  • Target XML Files with optional elements

    Hi All,
    I am using ODI 10.1.3.4. My task is to create an XML file of the following format:
    <parent count="2">
    <child>
    <name>Fred</name>
    <age>15</age>
    <email>[email protected]</email>
    </child>
    <child>
    <name>Bob</name>
    <age>5</age>
    *<email />*
    </child>
    </parent>
    I have been able to successfully create a target file. But the file does NOT contain the empty elements. ie the email element for Bob is missing from my target file.
    Is there any way to configure the XML connection or the "create xmlfile" command to output the empty element?
    Many Thanks
    Nat

    After speaking to BEA support it appears as though there is a partial solution to this issue. If you add the attributes minOccurs="0" nillable="true" to the elements then the SOAP message is correct. i.e.
    <xs:complexType name="SIDSearchCriteriaStructure">
    <xs:sequence>
    <xs:choice>
    <xs:element ref="SIDUniqueReference" minOccurs="0" nillable="true"/>
    <xs:element ref="SIDOtherCriteria" minOccurs="0" nillable="true"/>
    </xs:choice>
    </xs:sequence>
    </xs:complexType>
    I say that this is only a partial fix because elements cannot have minOccurs and nillable attribtes when they are references (as opposed to named elements - e.g. <xs:element name="SIDDNA" type="RestrictedStringType"/>). This is according to XMLSpy anyway. Don't know whether it's W3C legal though.
    Nick

  • XML portlet with XSLT

    What is the best way to use XSLT with the XML portlet, is it possible? Any suggestions would be helpful. Any good links on XML portlet examples?

    insert before line 9:
    app.activeDocument.xmlExportPreferences.allowTransform=true;
    app.activeDocument.xmlExportPreferences.transformFilename=File('PATH_TO_YOUR_TRANSFROM_FILE');

  • XML Export with XSLT

    Dear scripters,
    With this little script you can export XML.
    But is there an way you can use an XSLT to export the XML?
    var w = new Window ("dialog"); 
    var myBut = w.add ("button", undefined, "EXPORT", {name: "ok"}); 
    var myName = app.activeDocument.name.split(".indd").join(".xml"); 
    if (w.show() == 1){ 
        try { 
             var myFolder = Folder.selectDialog("Select the folder", "");  
             app.scriptPreferences.userInteractionLevel=UserInteractionLevels.neverInteract; 
             var myInxfile = new File(myFolder.fsName+"/"+app.activeDocument.name.split(".indd")[0]+".xml"); 
             app.activeDocument.exportFile(ExportFormat.XML, myInxfile); 
             } catch(err) {alert(err);} 
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
    XSLT:
    <?xml version='1.0' encoding='UTF-8' ?>
    <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
    <!-- Match everything --> 
    <xsl:template match="@*|node()"> 
    <xsl:copy> 
    <xsl:apply-templates select="@*|node()" /> 
    </xsl:copy> 
    <xsl:text> 
    </xsl:text></xsl:template> 
    </xsl:stylesheet> 
    Greetings

    insert before line 9:
    app.activeDocument.xmlExportPreferences.allowTransform=true;
    app.activeDocument.xmlExportPreferences.transformFilename=File('PATH_TO_YOUR_TRANSFROM_FILE');

  • How to access XML attributes with JSTL

    Hello,
    I'm using the XML functions of JSTL. I'm trying to parse the following RSS feed.
    http://weather.yahooapis.com/forecastrss?p=USNY0996
    I can get it parsed and access the elements via JSTL, but is it possible to access the attributes of some of the elements?
    For example, how can I get the city attribute out of
    <yweather:location city="New York" region="NY" country="US" />

    Hello,
    I'm using the XML functions of JSTL. I'm trying to parse the following RSS feed.
    http://weather.yahooapis.com/forecastrss?p=USNY0996
    I can get it parsed and access the elements via JSTL, but is it possible to access the attributes of some of the elements?
    For example, how can I get the city attribute out of
    <yweather:location city="New York" region="NY" country="US" />

  • How to query for XML-attribute with XPATH

    Hi,
    Isn't there somebody, who can tell me how to query an Attribut of an XML-element correctly ?
    All my trials lead to empty rows. What's worng in my XPATH-expresion ?
    XML-file looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <xmlexport>
    <itsystem guid="e51b91d1-ab0f-11db-2cd7-001641105333">
    <field fieldidentifier="currentVersion" />
    <field fieldidentifier="marketdatacosts">0</field>
    I can query fine the elements and sub-elements, but not attribute 'guid' of /xmlexport/itsystem. Here some trials, all lead
    SELECT t.* FROM CORIA."xmlexport156_TAB", xmltable ('/xmlexport/itsystem ' passing object_value COLUMNS
    GUID     VARCHAR2(1000) path '[@guid=*]') t
    various versions for Xpath:
    path '[@guid="*"]'
    path '/[@guid=*]'
    path '[@guid=*]'
    xmltable ('/xmlexport' ...
    path '/itsystem/[@guid=*]'
    ... combinations of part 1 and 2
    thanks for any hint, LaoDe

    You can either get them directly, or fetch the attribute in your xquery and put them in returning xml fragment, then get them like normal element.
    Method #1:
    path '@guid'
    Method #2:
    xmltable(
    let $is := /xmlexport/itsystem
    return <r><guid>{$is/@guid}</guid></r>
    passing object_value
    columns guid varchar2(1000) path '/r/guid')

  • Transfer 100M XML file with XSL

    Hi,
    I am trying to transfer 100M XML file with XSL. Input.xml is the XML file, format.xsl is the XSL file. I type in the command line as:
    java org.apache.xalan.xslt.Process -IN input.xml -XSL format.xsl -OUT output.xml
    It got "out of memeory" error. My questions are:
    1. Is it possible to transfer such large XML file with XSLT?
    2. The XSL processor used SAX or DOM to parse XML file?
    3. Any suggestions?
    Thanks.
    James

    maybe?
    java -Xmx200m org.apache.xalan.xslt.Process -IN input.xml -XSL format.xsl -OUT output.xml
    http://java.sun.com/j2se/1.3/docs/tooldocs/win32/java-classic.html

  • Using transform api with xslt and DOM Nodes

    Hi,
    when trying to transform a xml document with xslt using the javax.xml.transform api
    providing an element node of a previously parsed document, I find that absolute
    paths are not recognized.
    The following program shows what I am basically doing (the class can be executed
    on the command line providing a stylesheet and xml instance):
    import java.io.*;
    import org.w3c.dom.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    import javax.xml.parsers.*;
    class Transform {
    public static void main(String [] args) throws Exception {
         TransformerFactory tfactory = TransformerFactory.newInstance();
         Transformer transformer = tfactory.newTransformer(new StreamSource(args[0]));
         DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder parser = dfactory.newDocumentBuilder();
         Document doc = parser.parse(args[1]);
         Element domElem = doc.getDocumentElement();
         // workaround
    //     StringWriter out = new StringWriter();
    //     Transformer id = tfactory.newTransformer();
    //     id.transform(new DOMSource(domElem),new StreamResult(out));
    //     String xml = out.toString();
    //     transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(System.out));
         transformer.transform(new DOMSource(domElem), new StreamResult(System.out));
    transformer.clearParameters();
    If I use this on e.g.
    xsl:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes" encoding="ISO-8859-1" method="xml"/>
    <xsl:template match="/">
    <xsl:value-of select="/foo/bar"/>
    </xsl:template>
    </xsl:stylesheet>
    xml:
    <foo>abc<bar>def</bar></foo>
    I get
    <?xml version="1.0" encoding="ISO-8859-1"?>
    abcdef
    instead of
    <?xml version="1.0" encoding="ISO-8859-1"?>
    def
    I think this is due to the fact, that the transformation does not recognize
    any absolutely adressed xpath correctly.
    From what I read in the API docs, I think what I'm doing should be ok.
    So: did I misunderstand something or is this a bug in the java libraries?
    I'm using j2sdk 1.4.1_01 on i386 linux.
    If I use the commented code (serializing the xml and doing the transformation
    with a StreamSource, that has to be parsed again), everything's fine.
    Of course it would be easier to parse the file directly in the example but in the
    real program, I already have a dom tree and want to transform a part of it.
    Any help appreciated.
    Thanks, Morus

    why?
    that's all the point of XSL: define what part of your
    XML you want in your XSL templates, there is no need
    to prepare a sub-DOM of your DOM.
    Ok. Right. That's an alternative.
    The problem remains, that there are some stylesheets originally written
    for the current solution and though they should work with the whole document
    as well, it's not certain.
    Actually I don't know if this ever worked. I did neither write this code nor maintained the system so far.
    btw. you would be faster by giving a StreamSource to
    your transformation.Probably yes. But that would imply to rewrite a lot of code.
    What is happening is:
    there is a SOAP answser containing a xml document as the result parameter.
    The SOAP answer is parsed (I guess by the soap classes already) and the
    result xml is extracted. That's where the element node I'm trying to transform
    stems from.
    Besides, I still don't see why DOMSource takes any node if only document nodes
    work.
    Thanks, Morus

  • Read XML attributes

    I have this xml.
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <root>
         <file name="Bohy" type="folder">
              <file name=".dropbox" type="file" />
              <file name="Beck" type="folder">
                   <file name="desktop.ini" type="file" />
              </file>
         </file>
         <file name="Links.txt" type="file" />
         <file name="Pipo" type="folder">
         </file>
    </root>And I need read attributes name and type, but with my code is not works. Can you repair me. Thanks
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    * @author thomas lokol
    public class Main {
         private static DocumentBuilderFactory dbf;
         private static DocumentBuilder builder;
         private static Document doc;
          * @param args
         public static void main(String[] args) {
              createDocuments();
              // Root element
              Node node = doc.getDocumentElement();
              String rootElement = node.getNodeName();
              System.out.println("Root element: " + rootElement);
              readNodes(node.getChildNodes());
         private static void readNodes(NodeList nodeList) {
              System.out.println(nodeList.getLength());
              for (int i = 0; i < nodeList.getLength(); i++) {
                   Node node = nodeList.item(i);
                   if (node.getNodeType() == Node.ELEMENT_NODE) {
                        Element element = (Element)node;
                   if(node.getNodeType() == Node.TEXT_NODE) {
                         NamedNodeMap attributes = node.getAttributes();
                         // Here is problem ...
                         for (int a = 0; a < attributes.getLength(); a++) {
                           Node theAttribute = attributes.item(a);
                           System.out.println(theAttribute.getNodeName() + "=" + theAttribute.getNodeValue());
         private static void createDocuments() {
              try {
                   dbf = DocumentBuilderFactory.newInstance();
                   builder = dbf.newDocumentBuilder();
                   doc = builder.parse("myFile.xml");
              } catch (Exception e) {
                   System.out.println("Chyba pri vytvareni");
                   e.printStackTrace();
    }Edited by: EJP on 23/04/2012 11:43: added {noformat}{noformat} tags. Please use them. Also fixed your title.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Hi,
    I would suggest that you use a more simple library like Dom4j,
    It is quite easy to use and is proven to have good performance on heavy tasks.
    you can access xml attributes with a single line cod :
    String value = element.attributeValue("Attribute name");you can download and view samples here : http://dom4j.sourceforge.net/

  • Change a attribute value with XSLT before importing an XML

    I need change the attribute value with XSLT before importing an XML
    <table class="x" style="width="50pt">...
    I have to divide by 200 the value of "width", and the result multiplied by 100:
    (50/200) * 100
    It's possible with a XLST?

    Hi,
    Yes you can do this via XSLT.
    You can try similar to the one below:
    <table>
       <xsl:attribute name="width">
         <xsl:value-of select="((./width) div 200)*(100)" />
       </xsl:attribute>
    </table>
    I have not tested yet... Try it....
    Green4ever
    (I am back after long time)....

Maybe you are looking for

  • Not able to see tables in third party connection

    Hello All, I am using Sql Developer early adopter release to migrate from SQL Server to Oracle Database. I have created the third party sql server connection in sql developer. Although the migration process is sucessfull,but i cannot see the tables u

  • How to auto fill unicode text in "Form" of htm file?

    many records to fill and update through web could I fill the form automatically by computer while there some Asian wider code ( still unicode)? ( text file is there.) If you have code, just give me some. Thank you a lot.

  • My panorama feature is not working correctly on Ipod 5th gen? Help???

    It worked fine to begin with but now it doesmt seem to work properly and everytime i select it my camera graphics drop significantly.. The camera goes very fuzzy and dark and the final picture is grainy and covered in lines.. Please help? im running

  • How to set SQL trace in OCI session ?

    Hello, In a SQL*Plus session, I can use the SQL statement "alter session set sql_trace=true;" to set SQL trace in that session only. I assume I could execute the same SQL statement from C code in an OCI client and achieve the same goal. However, if I

  • Profit Center field in Material Master

    Hi all We have 9 plants. In 2 plants we want to do profit center field (MARC-PRCTR) mandatory in material master plant date/stor. 2 view.  There is any user exit or setting required? Please guide Regards