XSLT Transform XML 2 HTML does not work well

Hi,
This is my first attempt to use XSLT to convert my XML file into HTML using Java. I have included below the java code I used for the transformation, the xsl file and the xml file.
As per the xml file, I would like to display the carrier's common-name for each host. However, I can only get to display the carrier-id using the code line
<xsl:value-of select="./@carrier"/>
as shown in the last part of the xsl file, but cannot get the carrier's commonname from the carrierid using the code,
<xsl:variable name="hostCarr" select="./@carrier"/>
<xsl:variable name="hostcomName" select="id($hostCarr)/common-name"/>
<xsl:value-of select="$hostcomName"/>
However this works well if I were to use XML SPY for the conversion, instead of the Transform class in Java. I am using version 1.4.1 of Java.
Please help.
Thanks,
Prasuna
XML file
<pathinfo pathogen-name="Brucella spp.">
     <taxonomy>
          <carrier carrierID="wild">
               <common-name>Wild cies</common-name>
          </carrier>
          <carrier carrierID="sheepandgoats">
               <common-name>Domestic Pig</common-name>
          </carrier>
          <carrier carrierID="lab">
               <common-name>Laboratory environment</common-name>
          </carrier>
     </taxonomy>
     <host-list>
          <host carrier="wild"></host>
          <host carrier="lab"></host>
          <host carrier="sheepandgoats"></host>
     </host-list>
</pathinfo>
XSL file
<xsl:stylesheet version="1.0" xmlns:a="http://www.xmlspy.com/schemas/orgchart" xmlns:ipo="http://www.altova.com/IPO" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" omit-xml-declaration="no" indent="no" media-type="text/html"/>
     <xsl:template match="pathinfo">
          <html>
               <head><title><xsl:value-of select="@pathogen-name"/></title>
               </head>
               <body bgcolor="#ffffe5" text="#000000" link="#007a00" vlink="#7a0000" alink="#ff0000">
                    <xsl:apply-templates select="host-list"/>
               </body>
          </html>
     </xsl:template>
     <xsl:template match="host-list">
          <ol>
               <xsl:for-each select="host">
                    <li>
                         <xsl:variable name="hostCarr" select="./@carrier"/>
                         <xsl:variable name="hostcomName" select="id($hostCarr)/common-name"/>
                         <!--
                         <xsl:value-of select="./@carrier"/>
                         <xsl:value-of select="$hostcomName"/>
                         -->
                         <xsl:value-of select="$hostcomName"/>
                    </li>
               </xsl:for-each>
          </ol>
     </xsl:template>
</xsl:stylesheet>
Java Code
import javax.xml.transform.*;
import java.net.*;
import java.io.*;
public class Xml2Html {
public static void main(String[] args) {
try {
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer =
tFactory.newTransformer
(new javax.xml.transform.stream.StreamSource
("temp.xsl"));
transformer.transform
(new javax.xml.transform.stream.StreamSource
("temp.xml"),
new javax.xml.transform.stream.StreamResult
( new FileOutputStream("temp.html")));
catch (Exception e) {
e.printStackTrace( );

From Michael Kay's book "XSLT Programmer's Reference":
'A non-validating XML parser isn't required to read attribute definitions from an external DTD. In this situation the XSLT processor will assume there are no ID attributes present, and the id() function will always return an empty result."
Presumably you didn't set your transformer to use a validating parser, and I don't even see a reference to a DTD there. However the expression id('X') is equivalent to //*[@id='X'], Kay goes on to say. Try that instead.

Similar Messages

  • Safari 5.1.1 I no longer have access to my bookmark folders, just a search that does not work well. How can I retrieve access to bookmark folders?

    OS 10.6.8 Safari 5.1.1 I no longer have access to the bookmark folders. There is just a search function that does not work well. Is there any way to get access back to my bookmark folders?

    This site didn't say anything about one wrong ID, but only talks about changing the Apple ID.  If it didn't work the first time why should it work now?

  • TA48312 now my iphone4 version is 6.0.1, personal hotspot does not works well as before, so i want to upgrade back to the old version 4.3.5,please help me

    now my iphone4 version is 6.0.1, personal hotspot does not works well as before, so i want to upgrade back to the old version 4.3.5,please help me.

    Downgrading is Not supported by Apple.
    Unauthorized modification of iOS
    http://support.apple.com/kb/HT3743

  • Hi... i have iphone 5. my phone shows me the apple broken and does not work well . what this means? deppy

    hi... i have iphone 5. my phone shows me the apple broken and does not work well . what this means? deppy

    despoina kiato wrote:
    καμία φορά σταματάει να δουλεύει. σβήνει το κινητό και  μου δηχνει το μήλο σπασμένο.  απενεργοποιήτε  μόνο του . αυτό είναι όλο .
    Englidh would help.

  • HT4061 If my flash does not work well will Apple fix it

    My iPhone  camera flash does not work well, will Apple fix this tin store?

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V).
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

  • Bluetooth does not work well after upgrade to win 8.1 from win 8

    System:                       Dell Inspiron 15R 5520
    Bluetooth hardware:   Intel(R) Centrino(R) Wireless Bluetooth(R) 4.0 + High Speed Adapter
                                         Microsoft Bluetooth Enumerator
    Ever since I upgraded from Win 8 to 8.1, the bluetooth has not been working well.
    The option to browse a remote folder or send a file does not work. 
    I can send a file only by opening the contaning folder, right click, and send to bluetooth, but cannot receive a file unless I go to
    run and then open fsquirt.exe .
    I have unpaired and uninstalled the devices respectively, and then reinstalled and repaired them. But this does not work .either.
    Unfortunately, I am unable to paste  screenshots of the device manager and error messages until I am verified.
    Can anyone give me a solution to this problem?

    Verify that you have the latest drivers for Windows 8.1 installed from the manufacturer's website.
    http://www.dell.com/support/drivers/us/en/19/Product/inspiron-15r-5520

  • New FocusTraversalPolicy Mechanism Does Not Work Well With OO Designs

    I would like to complain about the new focus traversal mechanism not working well with object-oriented GUI designs.
    Specifically, we have many reusable panel classes that can be swapped in and out of reusable dialog classes. On some of these panels, the default focus traversal is not what is desirable, perhaps because one component on the right side of the window is just slightly higher than a component on the left side, maybe due to the component on the right having a label on top, and so the default focus goes to the component on the right instead of the left. So we have a need to be able to explicitly define the order of components in some panels.
    If I try to define a focus traversal policy in the panel's constructor, a NullPointerException is thrown because the panel's focus cycle root is null (the panel has not been added to any dialog or frame yet).
    If I try to associate a focus traversal policy at the dialog level, it would have to explicitly reference its child panels' inner components, which would break the encapsulation of the panels. It would also make it hard to have generic dialog classes into which various reusable panel objects can be swapped.
    Someone suggested making each panel a focus cycle root. This makes it hard to "break out" of one panel to move on to the next panel in the dialog. Special keys would have to be assigned to try to cycle out, and these keys would have to be different than the normal traversal keys, making them inconsistent and nonintuitive to the user. Also, the focus policy would have to know if the dialog had more than one panel, what order the panels were in to know whether to cycle to the next panel or not, etc. This is a mess.
    Does anyone have any idea how to get around these problems? I have tried using a global focus policy with a global hash map of prev/next component key-value pairs, but we are still running into trouble with some deeply nested tabbed dialogs. It's just not possible to always have the focus cycle root in existence at the point where you want to explicitly define traversal between two components, or when you are trying to establish the default component for a panel in a tabbed pane.
    Has anyone else run into similar issues?
    Robbie Gilbert
    [email protected]

    I agree completely. One of the popular consultants on this forum stated that the new focus mechanism was more versatile and only a little more complex. I would say it's more than a little complex given the trouble average programmers are having understanding how it works...at least at first...and after understanding it realizing that they are going to have type their fingers off to update their code. Oh, and the dread of maintaining this awful mess.
    I'm currently having the same problem as you Robbie. Some of my reusable panels need special tab ordering...that's not usually a problem, in most programming environments, till now. Now I have to go around the world and back just to get my stupid cursor to be in the right place when I hit the tab key??!!! and special key mappings just to get out of a focus cycle...lame.
    And how is an IDE graphical designer going to work with this? It's not, that's how...ok maybe if some kind person or company creates a custom focus traversal policy editor of some kind, I don't know.
    Good grief Sun! We need something to help us meet our deadlines, not solutions that force us to spend 80% of our time customizing every stinking bit of UI functionality we need!!!
    JTables are even worse. I've mastered most of the garbage that is JTable after many months of pain and I don't know how I'm going to help my peers understand them in any short amount of time. Most of them were Oracle Forms programmers, not that that is any great solution either. But they will likely have problems.
    In conclusion, I wish I had chosen another UI technology for our new product client, and may yet.

  • Simple 960px html does not work???

    I've b een coding pages a while but this has me perplexed.
    I have a page with simple code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    #960Wrapper {
    width: 960px;
    background-color: #0F0;
    margin-right: auto;
    margin-left: auto;
    #header {
    background-color: #C9F;
    #footer {
    background-color: #C0F;
    </style>
    </head>
    <body>
    <div id="960Wrapper">Content for  id pageWrapper Goes Here
            <div id="header">This area is reserved for logo</div>
        <div id="contentArea">
       <p>Please click a button:</p>
      </div>
         <div id="footer">This area is reserved for footer</div>
      </div>
    </div>
    </body>
    </html>
    However everything is going to full width and edge of the browser - all of them.
    Maybe my grey cells are tired - or something is corrupt but the machine does not accept it - in or out of dreamweaver.
    I've rebooted - run ccleaner and rebooted again but something is not working for me.
    I'd appreciate if someone could confirm I'm not going mad please.
    Terry

    GROAN!
    Forgot about that one - it's as simple as that???!
    I had a whole page written and then it stopped working - I've even stripped it back to basics and it was as simple as that???
    Thank you very much for pointing this out.
    Terry

  • Help, my Bridge does not works well with my AfterEffect. does not preview .ffx files

    Hi,
         I have some problem with my Bridge. When i browse preset from my After Effect in Bridge, it won't preview all of the After Effect preset(*.ffx), but my Bridge works well with photoshop files, it will preview all the photo files inculding .PSD. Does anyone knows what's the problem? Anyone knows how to fix it? I need help to fix this problem to get my work in AfterEffect, it is very hard to get things work it won't preview the preset. Thanks.
    Best Regrads,
    Chongkkmy

    Found this link, does it address your problem?
    http://forums.adobe.com/click.jspa?searchID=769246&objectType=2&objectID=1794899

  • DNG 5.4 does not work well with Olympus E-620

    I just installed the DNG converter 5.4 to use with the RAW ORF files from my new Olympus E-620.  The converted images are not the same as the jpg images or the RAW images as converted by the Olympus Master software.  They are duller in the highlights and darker in the shadows.  The difference is NOT small and is readily noticeable in the image and when comparing the histogram.  It looks like part of the problem may be that the Olympus automatic gradation may not be interpreted properly, but the difference is even more than just this.  I can turn this on and off in the Olympus Master and the difference is similar but a greater difference than just this alone.  Further, the Olympus Master software cannot open the DNG files.
    I would also like to rgister my high dissatisfaction with the short life of the Adobe software due to the new RAW converters not working with older Photoshop or Lightroom software versions.  I am using Lightroom 1.2 and PS CS3, and I do not want to spen the considerable cost of upgrade only to be able to convert my RAW files.  Also, I do not like to have to convert my RAW files to DNG first, because I loose some of the editing options that I can only do in the Olympus software, and it creates another step in my workflow.

    shedridc wrote:
    The converted images are not the same as the jpg images or the RAW images as converted by the Olympus Master software. 
    Well, doh...since Camera Raw is using it's own processing parameters and algorithms, the odds of ACR "matching" the camera makers software is not real high. At some point when ACR 5.4 is finally released Adobe may have some additional DNG Profiles for the camera that may make color a closer match but the tone curve will prolly always needs tweaks. It would behoove you to either create presets that you can apply in Bridge or alter your ACR "Defaults".
    shedridc wrote:
    I would also like to rgister my high dissatisfaction with the short life of the Adobe software due to the new RAW converters not working with older Photoshop or Lightroom software versions.
    It's been Adobe's policy to only support currently shipping products. As such, customers who upgraded to Ps CS4 can expect about 18 months of free support and Camera Raw updates. Fact is that while you WERE a current customer when you bought CS3 and you got 6 free ACR updates (ACR 4.6 was the last version for CS3), you are no longer a current customer.
    You may not like the DNG Converter step, but that's what you have if you wish to use your new camera with your old software...your other alternative is, of course to simply use the software that came with your camera.

  • Aperture 3 does not work well since installing Mavericks. Constantly have to repair the library database. Any suggestions?

    Aperture 3.5.1 was working well enough for me in Mountain Lion, but it seems that switching to Mavericks has made it slower, made it crash frequently and also given me frequent messages that the database is corrupt and I need to rebuild the database library, which I have done multiple times. I also use Aperture for Photo Stream, and it is especially slow and problematic there. Any ideas? Should I just use iPhoto instead? I'm more familiar with the flow in Aperture and would need to learn how better to use iPhoto, so that would be a last resort for me.

    Aperture 3.5.1 was working well enough for me in Mountain Lion
    Aperture 3.5.1 is incompatible with Mt. Lion - you  must have had an earlier Aperture version running with Mt. Lion.
    also given me frequent messages that the database is corrupt and I need to rebuild the database library
    That message is prompted by the crashes. After a crash your library may need repairing.
    Aperture 3.5.1 was working well enough for me in Mountain Lion, but it seems that switching to Mavericks has made it slower, made it crash frequently
    Is all your software compatible with Mavericks? Plug-ins, external editors, preference panes, device drivers, video codecs? Did you install any other software, when you upgraded to Mavericks?
    Where is your Aperture library? On your system drive or external drive?
    Does Aperture also crash, if you launch it while holding down the Shift key?

  • Mail does not work well with lion

    Cannot shut off my computer because Mail does not close since i installed lion

    Cannot shut off my computer because Mail does not close since i installed lion

  • Spry xml data does not work in ie

    Hello all,
    I'm attempting to use a spry data set / xml. Works great in FF. I can't get it to function in IE. On my test machine, it will blink the html content without the xml data and then just disappear. No error. I've created a simple test page for trouble shooting. I'm using Spry version 1.6.1.
    Can you please take a look and see if you can tell what I'm doing wrong? Thanks in advance.
    Links to the test pages:
    http://psstudios.com/clients/tesseract/caltest.htm
    <meta http-equiv="Content-Type" content="text/xml; charset=UTF-8" />
    http://psstudios.com/clients/tesseract/caltest1.htm
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    and the xml:
    http://psstudios.com/clients/tesseract/tesseract_events.xml
    http://psstudios.com/clients/tesseract/tesseract_news.xml

    Your server is sending xml files with the content-type header text/plain. XML files should have the content-type text/xml. If you fix this, it would work. If you cannot change the server settings to serve the appropriate header see my post over at the Spry forums: http://forums.adobe.com/message/2179253#2179253
    It might fixes the issue for you, but that still doesn't mean it would fix your server

  • Links in HTML TextField not working well on iPad

    Hi there;
    I've got a TextField with html in it that has anchors that call out to Flash functions using the href="event:" mechanism.
    It works 100% fine when I test my fla on my Mac... ie. Clicking on the links is responsive, and all works as expected.
    When I publish this to the iPhone or iPad, the links work, but only after I click them 2 or 3 times. It *seems* like the stroke of the font is the only clickable part.... It feels like clicking in the center of a letter "O" wouldn't work, and clicking the strokes of the letter "O" would...
    The links are very big... and there are about 20 of them on the page.
    Has anyone else run into this problem? I've tried using css styles to set display:block, but that didn't seem to help!
    Thanks,
    Brad

    had this all typed in earlier today just when we had a major power outage and lost it, plus restraining myself from tossing the IPAD and sticking to Android mobile!
    anyways, per your message, tried to rework my app here as well and this method seems to work for me with item still to be worked out per notes below.
    overview:
    using TLF CS5.5
    use TouchEvent listener on my containers to return textline being touched
    once touched, loop through all spans and if parent is a link, get the textline associated with that link
    if match then jackpot, return,
    some rough code below,
    where this fails is when my link rambles over several lines and it's only recognizing the first line of the link. Otherwise, all links in all containers respond well.
         function taphandler(event:TouchEvent): void {
           var leaf:SpanElement;
           var link:LinkElement;
           var absoluteStart:int;
           var matchTextLine:TextLine;
           leaf = SpanElement(TLF2.textFlow.getFirstLeaf());
           while (leaf = SpanElement(leaf.getNextLeaf())) {
             link = leaf.getParentByType(LinkElement) as LinkElement;
             if (link != null){
               absoluteStart = link.getAbsoluteStart();
               matchTextLine = link.getTextFlow().flowComposer.findLineAtPosition(absoluteStart).getTextLine(true);
                if(matchTextLine==event.target){
                  //JACKPOT! use link.href         
                  return;
    i welcome any input to code (i think i miss out if i have a link in first span which I should not have but..) and how to get at the second, third, fourth,.. lines of the link.  hopefully someone in the TLF area can explain the quantity and hierarchy of the objects of the links that are spread over many lines since from a user perspective we just see text, mind you high quality and very intelligent text and Adobe should be commended.
    UPDATE:
    as it worked above, a sample textline with plain text and 3 links, clicking anywhere on the textline always gives me link#1 unfortunately.
    seems like I need a for loop just before the matchTextLine that iterates i=(link.parentRelativeEnd-link.parentRelativeStart) times, then must do a GetAtomBounds LocalToGlobal compare to Stage.x then modify the line if(matchTextLine==event.target){  to if(matchTextLine==event.target&&thisLinkIsAtX==true){      ouch I hope I don't have to do all this..
    Message was edited by: hiteck7

  • XSLT transformer of CQ is not working for properties other than property named as "text"

    At the location "/libs/wcm/core/content/pdf/page2fo.xsl", of CQ 5.5 instance, I can see a transformer that converts the geometrixx pages to pdf. For the text component of foundation the code "<xsl:apply-templates select="text"/>" transforms the Rich Text of text component to PDF removing all the markup. Now If I change the property name of the "Text" component from "text" to "mytext", the PDF is not able to show the RTE content anymore. Any idea why the name of the property can't be changes?

    Hi,
    You have to debug the entire system behaviour , the approval process using the second approver.
    As first step , please check the security level of the second approver. Restart of workflow is based on the security level of the approver.
    you can find the parameter for security level in the personalization tab of the user .
    there is one function module  which determines wether the workflow should be restarted (or) not.
    i do not remember the exact name of the function module.
    1)start transaction se37
    2)enter bbpwflrestart*.
    3) system will return a number of function modules , of them one function module determines wether to restart the workflow (or) not.
    Please check what does the above function module return for the user and the shopping cart , there will be one parameter 'restart' which triggers the start

Maybe you are looking for