Not getting required output from XML transform in servlet

I have an XML document and an XSL stylesheet that will produce the output I require when I use the Xalan in-line parser. However, I cannot manage to do the same in a servlet. I have trawled through loads of examples but can't find anything that works. It appears that the servlet is choking when I try to use:
Document document = builder.parse(datafile);
and the output in the browser is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>
Which bears no resemblance to what I am expecting.
I can provide contents of servlet source and xml files if someone can help, please.

Thanks for your comments.
I have tested the XML and XSL and they are OK but the servlet won't sned out the HTML as expected.
The servlet code is as follows (I haven't included the whole servlet - just the core of the body):
public class FormTwo extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException, FileNotFoundException {
res.setContentType("text/html");
//PrintWriter out = res.getWriter();
PrintStream out = new PrintStream (res.getOutputStream());
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
TransformerFactory tFactory = TransformerFactory.newInstance();
try {
  File stylesheet = new File("children.xsl");
  File datafile   = new File("children.xml");
  int NumChildren = Integer.parseInt(req.getParameter("Numchildren"));
  String fullname = req.getParameter("Title") + " " + req.getParameter("Lastname");
  DocumentBuilder builder = factory.newDocumentBuilder();
  Document document = builder.parse(datafile);
  // Use a Transformer for output
  StreamSource stylesource = new StreamSource(stylesheet);
  Transformer transformer = tFactory.newTransformer(stylesource);
  DOMSource source = new DOMSource(document);
  StreamResult result = new StreamResult(out);
  transformer.transform(source, result);
}The XML is:
<?xml version="1.0"?>
<pagedef pagehead="Form two test page">
     <bodydef bodytext=", could you please enter details of each child and indicate if they are currently at school">
          <rows NumReq="3">
               <cols type="text" size="25" name="firstname">First Name</cols>
               <cols type="text" size="25" name="lastname">Last Name</cols>
               <cols type="checkbox" name="atschool">At school?</cols>
          </rows>
     </bodydef>
</pagedef>The XSLT is:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          xmlns="http://www.apache.org/xslt">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
  <html>
  <head><title><xsl:value-of select="/pagedef/@pagehead"/></title></head>
  <body bgcolor="#ffffcc" text="#0000ff">
  <xsl:apply-templates/>
  </body>
  </html>
</xsl:template>
<xsl:template match="bodydef">
  <xsl:value-of select="@bodytext"/>
  <form>
  <table>
  <xsl:apply-templates/>
  </table>
  </form>
</xsl:template>
<xsl:template match="rows">
  <thead>
  <xsl:for-each select="cols">
  <td><xsl:value-of select="."/></td>
  </xsl:for-each>
  </thead>
  <xsl:call-template name="output-row">
  <xsl:with-param name="thisrow" select="0"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="output-row">
  <xsl:param name="thisrow"/>
  <xsl:choose>
  <xsl:when test="number($thisrow) != number(/pagedef/bodydef/rows/@NumReq)">
  <tr>
  <xsl:for-each select="cols">
  <td>
  <input>
  <xsl:copy-of select="@*"/>
  </input>
  </td>
  </xsl:for-each>
  </tr>
  <xsl:call-template name="output-row">
  <xsl:with-param name="thisrow" select="number($thisrow) + 1"/>
  </xsl:call-template>
  </xsl:when>
  <xsl:otherwise/>
  </xsl:choose>
</xsl:template>
</xsl:stylesheet>As a newbie to Java I am more confident about the XML and XSL than the servlet code. Any advice would be appreciated.
Thanks...

Similar Messages

  • I am not getting any output from the speakers of the ipad. However the sound is ok if i use headphones. Can anyone help?

    I am not getting any output from the speakers of the ipad. However the sound is ok if i use headphones. Can anyone help?

    1. Check the Side Switch
    http://i1224.photobucket.com/albums/ee374/Diavonex/00bf6eae.jpg
    2. Double-click the Home button and swipe to the right and check volume control
    http://i1224.photobucket.com/albums/ee374/Diavonex/ea5b842d.jpg
    3. Settings>Notification>Game Center>Sound>ON
    http://i1224.photobucket.com/albums/ee374/Diavonex/67a15edf.jpg

  • I am not getting required output after importing xml file having HTML tags, MathML and Latex code

    I created well formatted xml having html tags, MathML code and Latex code inside
    XML with sample latex
    <question>
        <p> 8. In this problem, <Image  style="vertical-align: -9pt" title="5a\frac{7b}{3}" alt="5a\frac{7b}{3}" href="http://www.snapwiz.com/cgi-bin/mathtex.cgi?%205a%5Cfrac%7B7b%7D%7B3%7D%0A"></Image> and <Image href="http://www.snapwiz.com/cgi-bin/mathtex.cgi?%207b%5Cfrac%7B5a%7D%7B3%7D" style="vertical-align: -9pt" title="7b\frac{5a}{3}" alt="7b\frac{5a}{3}"> </Image>are both mixed numbers, like <Image src="http://www.snapwiz.com/cgi-bin/mathtex.cgi?%203%20%5Cfrac%7B1%7D%7B2%7D%20=%203.5" style="vertical-align: -9pt" title="3 \frac{1}{2} = 3.5" alt="3 \frac{1}{2} = 3.5"></Image>. The expression <Image style="vertical-align: -9pt" title="5a \frac{7b}{3} \ \times 7b \frac{5a}{3}" alt="5a \frac{7b}{3} \ \times 7b \frac{5a}{3}" href="http://www.snapwiz.com/cgi-bin/mathtex.cgi?%205a%20%5Cfrac%7B7b%7D%7B3%7D%20%5C%20%5Ctimes %207b%20%5Cfrac%7B5a%7D%7B3%7D"> </Image>is equal to which of the following choices? </p>
    </question>
    XML with sample html tags
    <p>4. Examine the expression 3<i>k</i><sup>2</sup> + 6<i>k</i> - 5 + 6<i>k</i><sup>2</sup> + 2.</p><p>When it is simplified, which of the following is the equivalent expression?</p>
    XML with sample MathML tags
    <p>5. Find the vertex of the parabola associated with the quadratic function <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>y</mi><mo> </mo><mo>=</mo><mo> </mo><mo>-</mo><msup><mi>x</mi><mn>2</mn></msup><mo> </mo><mo>+</mo><mo> </mo><mn>10</mn><mi>x</mi><mo> </mo><mo>+</mo><mo> </mo><mn>4</mn></math></p>
        <math xmlns="http://www.w3.org/1998/Math/MathML"><mfenced><mrow><mo>-</mo><mn>5</mn><mo>,</mo><mo> </mo><mn>69</mn></mrow></mfenced></math><br>
        <math xmlns="http://www.w3.org/1998/Math/MathML"><mfenced><mrow><mn>5</mn><mo>,</mo><mo> </mo><mn>29</mn></mrow></mfenced></math><br>
        <math xmlns="http://www.w3.org/1998/Math/MathML"><mfenced><mrow><mn>5</mn><mo>,</mo><mo> </mo><mn>69</mn></mrow></mfenced></math><br>
        <math xmlns="http://www.w3.org/1998/Math/MathML"><mfenced><mrow><mo>-</mo><mn>5</mn><mo>,</mo><mo> </mo><mn>29</mn></mrow></mfenced></math>
    None of the above works fine after importing xml to Indesign document/templete, it is not renderting equivalent out instead it is showing the same text inside tags in the Indesign document.
    I have lot of content in our database, I will export to XML, import to Indesign, Indesign should render required output like what we see in the browser and export the output to printed format.
    Import formated XML to indesign --> Export to Quality Print Format
    Can any one guide me and let me know whether it is posible to do with Indesign, if so let me know in case if I am missing anything in importing xml and get required output.
    Thanks in advance. Waiting for reply ASAP.

    Possibly your expectations are too high. ... Scratch that "possibly".
    XML, in general, cannot be "rendered". It's just an abstract data format. Compare it to common markup such as *asterisks* to indicate emphasized words -- e-mail clients will show this text in bold, but InDesign, and the vast majority of other software, does not.
    To "render" XML, HTML, MathML, or LaTeX -- you seem to freely mix these *very* different markup formats, unaware of the fact that they are vastly different from each other! -- in the format you "expect", you need to apply the appropriate software to each of  the original data files. None of these markup languages are supported natively by InDesign.

  • Cosuming web service using consumer proxy - not getting the output

    Hello All,
    I am not getting the consumer proxy output structue filled though the web service is successfully executed. I did the following steps.
    1. Created a webservice form RFC BAPISDORDER_GETDETAILEDLIST
    2. Created a consumer proxy for the above created WSDL document.
    3. Tested the service by executing the proxy directly by feeding the input in the XML (sales document and partner view). it is working fine
    4. Created a program to access the consumer proxy by passing the input(same input as per XML). I am not getting the output in the proxy output structure ( but I can see the RFC is successfully executed and having the right values in the debugging mode).
    Is this the issue is due to the date fields (XML cannot consider a blank date )?
    Please note: the partner output table parameter in the bapi (output I am looking for ) is not having any date fields.
    Please help me to sort out this issue.
    Thanks,
    Gopi

    Hi Gopi,
    From your description, I assume you used the SE37 transaction's menu option Utilities -> More Utilities -> Create Web Service -> From the Function Module, to expose the BAPI concerned as a Web Service.
    If this is the case, then it is possible that you are falling foul of your SAP User ID not having the necessary Remote Function Call authorization to execute the BAPI.
    A prerequisite for successfully calling an RFC-enabled Function Module (which is what a BAPI is) is that the User ID used to call the function module must have the required RFC authorization (Authorization Object S_RFC).  For example, when calling function module BAPI_CUSTOMER_GET_ROOT, if the User ID lacks the requisite authorization in the target system, the following error message will be received by the Consuming application:
        User <User ID> has no RFC authorization for function group V02HBAPI.
    Notice, as you can see from the above message, RFC execution authorization is implemented at the Function Group level, not at the Function Module level.  In othere words, granting a user the authorization to a function group (authorization object S_RFC) enables the user to execute all RFC-enabled function modules contained within that function group.
    I am guessing the BAPI works for you in debug mode because you are not calling the BAPI remotely.
    Let me know if this helps.
    Best Regards,
    Andy.

  • Getting the output from a Perl script using Runtime.exec

    I cannot get the output from a perl script using Java. Can someone PLEASE help?
    I used the following code:
    Process p = Runtime.getRuntime().exec("C:\\Perl\\bin\\Perl.exe script.pl) ;
    InputSream in = p.getInputStream();
    b...
    do
    System.out.println(b);
    while ((b = in.read()) > 0)
    But there is no way that I get the output in the inputstream. If I use the command "cmd script.pl", the output is displayed in the Dos box, but also not in the inputstream.
    I will appreciate any help.

    Try this
    Process p = Runtime.getRuntime().exec("C:\\Perl\\bin\\Perl.exe script.pl) ;
    BufferedReader rd = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String str;
    while((str=rd.readLine())!=null){
    System.out.println(str);
    Manu

  • Not getting any output when running the Webservice through Xacute

    hai all,
    I am using a transaction as web service to be called in another transaction in the same server. I can see the output of the web service in the tracer, when I execute it in the BLS. But if I run the same transaction via xacute query I am not getting any output. I had read in one of the threads that reference document has to be assigned. I tried doing that also, but no luck. Can somebody pls. throw some light on how to use reference document & whether it is required in my case?
    Thanks,
    vidhya

    Hai Rick,
                    thanks for the hint i have used document and row actions now iam gettting output through xacute...
    thanks,
    vidhya.

  • My UR12 Steinberg interface is recognized by Yosemite but I can't get any output from the device, does anyone know how to fix this problem? Thanks in advance

    My UR12 Steinberg interface is recognized by Yosemite but I can't get any output from the device, does anyone know how to fix this problem? Thanks in advance

    Apparently it's related to the Firefox plug in.
    This isn't exactly a solution but more of a way to avoid opening PDFs with Firefox's plug in.
    1. Highlight "Tools" from the Menu Bar in the top left of the screen (or click "Options" if using the Firefox Compact Menu)
    2. Select to "Options
    3. Select "Applications"
    4. Look for "Adobe Acrobat Document" under Content Type and to the right under Action select "Use Adobe Reader (default)" instead of the using Adobe Acrobat in Firefox
    5. Open a test PDF. It should open in it's own window now.
    Again, not a complete solution but something that'll at least let you scroll with PDFs open.
    More info here: http://forums.mozillazine.org/viewtopic.php?f=38&t=2171033

  • Tax code not getting picked up from PO during SES

    Dear Experts,
    I am looking for configuration where the end user need not enter Tax code during SES. I tried a scenario where I did not maintain any service master and also did not enter any line item in service tab at item level, rather I processed my PO using limits.
    Now when I prepare SES using this PO, Tax code is not getting picked up from PO and some tax code(I1) appears. Since I don't want end user to input any tax code I've left it blank.
    Finally when I am doing MIRO, i am not able select the desired Tax code(say I8) as it is not available for selection. I get only one Tax code(say I1) available for selection. Even other Tax codes are not available for selection.
    Please advise, how do I resolve this, why is the Tax code not getting picked up in SES? and why am I not getting other tax codes for selection in MIRO?
    Thanks and Regards
    Mansih

    Hi,
    Tax for service maintained in the service PO in the INVOICE TAB in item details. You are not going to maintain the service tax during SES. In SES you are just recognizing / confirming the vendor performed /completed the required service given to him.
    During invoice tax code will flow from service PO to Invoice & you need to just select check box u201Ccalculate taxu201D & remove default tax code in MIRO, if any tax code set for default entry in MIRO. If you want your service tax code should appear in the MIRO screen then just activate in t.code:OBZT (relevant for all transaction),then  you can select your service tax code during invoice verification WRT service PO.
    Regards,
    Biju K

  • Step after getting required OUTPUT

    Hi all,
    I have been given the required output from the client in an excel spread sheet. Now that I know what kind of out put the client needs:
    WHAT IS MY NEXT STEP?
    What do i need to do to find out what fields they are and what InfoObjects they belong to?
    How do i determine what datasources i need to use (RSA5)?
    Thanks

    Hi,
    The Data is not available in BW.
    Lets say one of the ECC fields is BUKRS (Company Code). Do I now need to find out what TABLE (Source Table) this field is stored in? How does that help me?
    If yes, how can i do that?
    Edited by: SAPPER BI on Mar 6, 2008 7:52 PM

  • Siri could not download required information from the server

    I'm getting the message "siri could not download required information from the server". I haven't been able to use SIRI for 5 days. Does anyone know an answer?
    I've tried turning SIRI off, rebooting, and turning it back on. You know, the old PC approach.
    I have an excellent WI-FI connection.

    Not an answer but I do know if I do not have a good internet connection (3G or WiFi) I get that same error. Has always cleared up for me once that was resolved.

  • How to get string value from xml in JSF??

    In JSF How to get string value from xml, .ini and properties file. I want to get string value from xml or text to JSF

    Just use the appropriate API's for that. There are enough API's out which can read/parse/write XML, ini and properties files. E.g. JAXP or DOM4J for xml files, INI4J for ini files and Sun's own java.util.Properties for propertiesfiles.
    JSF supports properties files as message bundle and resource bundle so that you can use them for error messages and/or localization.

  • HT1454 why i can not get video out from my ipod touch after i did the upgrade

    why i can not get video out from my ipod touch after i did the upgrade

    why i can not get video out from my ipod touch after i did the upgrade

  • HT1454 Can not get video out from my ipod touch 3rd gen. Any ideas? It should nt be diffiicult to do this on the 21 st century, or not?

    After having spent EUR 130 on cables from apple, i still can not get video out from my ipod touch 3rd gen. Any ideas? It should nt be diffiicult to do this on the 21 st century, or not?

    Backing up an iOS device will copy some data to a backup file within iTunes, but this excludes all media.  You can also transfer iTunes Store purchases from the iDevice to iTunes but, without using a third-party tool, nothing else.  As long as you do not sync the iPod with your new library, the media that's on it will remain ... for as long as it keeps functioning, is not lost, stolen, eaten by the dog, ...
    You may also have an option to recover your previous library from your old laptop; as long as its hard drive isn't fried, a computer repair store or technician may be able to extract the drive, mount it in an external enclosure, and copy your data to another PC.  Whatever you choose, there is no real alternative to having all your media on your computer, managed by iTunes, and regularly backed up to another device/location.

  • I have just recently installed ios6 to my iPad 3 an iPhone 4 my iPhone works fine but my iPad is not working at all I can not get a response from it, it seemed to download an then install but did not reset and turn on and will not turn on HELP!! Withdrawa

    I have just recently installed ios6 to my iPad 3 an iPhone 4 my iPhone works fine but my iPad is not working at all I can not get a response from it, it seemed to download an then install but did not reset and turn on and will not turn on HELP!! Withdrawal or what!! Lol

    Hi there,
    Firstly, try a hard reset. Hold the sleep/wake and home buttons together until the Apple logo appears.
    If this doesn't work, try restoring your device. Put it in recovery mode if iTunes doesn't recognise it, and restore it from there. I have linked to instructions below.
    Recovery Mode and Restore - Apple
    Let me know if this helps,
    Nathan

  • Solution Manager does not get service definitions from SAP in self diagnosi

    Hi,
    In our production solution manager transaction solution_manager, self diagnosis we are getting a warning message on our development solution manager. 
    Solution Manager XXX does not get service definitions from SAP.
    The production Solution Manager is the master in SDCCN for the test Solution Manager.  In the test Solution Manager, the scheduled task REFRESH SERVICE DEFINITIONS has task System ID of O01.  It is pointed to RFC destination SDCC_OSS, not the production Solution Manager system.
    It gives the same warning if I point the task to the production Solution Manager system.
    Has anyone seen this before?  Any ideas?
    Best regards,
    Russ

    Hi,
      i guess have you activated SDCCN from your solution manager system too?
    if not please activate. since that setup helps solman retrive the service definitions used in SDCCN from SAP (SAPOSS).so this ultimately allows you to set solution manager system as Master, so all the satellite system get the service definition from solman and do not need a direct SAPOSS connection.
    and Please check this Note 1143775 - SAP service content update
    the wiki for trouble shoot ["EarlyWatch Alert is Red Flagged - how to resolve" |http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=228262728]
    please check.
    Thanks,
    Jansi

Maybe you are looking for