?
Solved

Need help in preparing XSL Template

Posted on 2004-11-03
12
Medium Priority
?
210 Views
Last Modified: 2010-03-31
 <?xml version="1.0" ?>
- <a:multistatus xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:d="urn:schemas:httpmail:" xmlns:e="urn:schemas:mailheader:" xmlns:c="xml:" xmlns:a="DAV:">
- <a:response>
  <a:href>http://192.12.0.38/exchange/administrator/Deleted%20Items/test%20mail%20to%20admin.EML</a:href>
- <a:propstat>
  <a:status>HTTP/1.1 200 OK</a:status>
- <a:prop>
  <d:hasattachment b:dt="boolean">0</d:hasattachment>
  <e:message-id><8762EB2772D3E747BFCA87262E7D48D8196A@comp38.ad.exchange3></e:message-id>
  <e:date b:dt="dateTime.tz">2004-09-08T08:49:42.769Z</e:date>
  <e:from>"Administrator" <Administrator@ad.exchange3></e:from>
  <e:to>"Administrator" <Administrator@ad.exchange3></e:to>
  <d:displaycc />
  <e:received>by comp38.ad.exchange3 id <01C49580.C8A2F450@comp38.ad.exchange3>; Wed, 8 Sep 2004 08:49:42 -0000</e:received>
  <e:subject>test mail to admin</e:subject>
  <d:textdescription>test mail to admin</d:textdescription>
  </a:prop>
  </a:propstat>
  </a:response>
  </a:multistatus>




Friends,

Truely speaking I am very poor in working with XSLT/Xalan while I was good in using Xerces parser. I can handle above xml using parsers but my client needs to have template  for this. So please help me in preparing the template on this

And a Java example to handle above XML and XSL template

Thanks
Sudhakar
0
Comment
Question by:sudhakar_koundinya
  • 9
  • 3
12 Comments
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 12490536
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 12490556
Mick,

can you please explain the template part from the BasicXsl example


Thanks
Sudhakar
0
 
LVL 92

Assisted Solution

by:objects
objects earned 2000 total points
ID: 12490574
Thats your xsl, it defines the template for the output

http://www.w3schools.com/xsl/xsl_languages.asp
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 12490807
javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Prefix must resolve to a namespace: a
      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:946)
      at BasicXsl.xsl(BasicXsl.java:18)
      at BasicXsl.main(BasicXsl.java:40)
Caused by: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Prefix must resolve to a namespace: a
      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:942)
      ... 2 more
Caused by: javax.xml.transform.TransformerException: Prefix must resolve to a namespace: a
      at org.apache.xalan.processor.XSLTAttributeDef.processPATTERN(XSLTAttributeDef.java:633)
      at org.apache.xalan.processor.XSLTAttributeDef.processValue(XSLTAttributeDef.java:926)
      at org.apache.xalan.processor.XSLTAttributeDef.setAttrValue(XSLTAttributeDef.java:1078)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:375)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:311)
      at org.apache.xalan.processor.ProcessorTemplateElem.startElement(ProcessorTemplateElem.java:122)
      at org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:656)
      at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:934)
      ... 2 more
---------
javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Prefix must resolve to a namespace: a
      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:942)
      at BasicXsl.xsl(BasicXsl.java:18)
      at BasicXsl.main(BasicXsl.java:40)
Caused by: javax.xml.transform.TransformerException: Prefix must resolve to a namespace: a
      at org.apache.xalan.processor.XSLTAttributeDef.processPATTERN(XSLTAttributeDef.java:633)
      at org.apache.xalan.processor.XSLTAttributeDef.processValue(XSLTAttributeDef.java:926)
      at org.apache.xalan.processor.XSLTAttributeDef.setAttrValue(XSLTAttributeDef.java:1078)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:375)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:311)
      at org.apache.xalan.processor.ProcessorTemplateElem.startElement(ProcessorTemplateElem.java:122)
      at org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:656)
      at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:934)
      ... 2 more
---------
javax.xml.transform.TransformerException: Prefix must resolve to a namespace: a
      at org.apache.xalan.processor.XSLTAttributeDef.processPATTERN(XSLTAttributeDef.java:633)
      at org.apache.xalan.processor.XSLTAttributeDef.processValue(XSLTAttributeDef.java:926)
      at org.apache.xalan.processor.XSLTAttributeDef.setAttrValue(XSLTAttributeDef.java:1078)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:375)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:311)
      at org.apache.xalan.processor.ProcessorTemplateElem.startElement(ProcessorTemplateElem.java:122)
      at org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:656)
      at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:934)
      at BasicXsl.xsl(BasicXsl.java:18)
      at BasicXsl.main(BasicXsl.java:40)
---------
; Line#: 25; Column#: 34
; Line#: 25; Column#: 34
javax.xml.transform.TransformerException: Prefix must resolve to a namespace: a
      at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:602)
      at org.apache.xpath.compiler.Lexer.mapNSTokens(Lexer.java:674)
      at org.apache.xpath.compiler.Lexer.tokenize(Lexer.java:397)
      at org.apache.xpath.compiler.Lexer.tokenize(Lexer.java:139)
      at org.apache.xpath.compiler.XPathParser.initMatchPattern(XPathParser.java:193)
      at org.apache.xpath.XPath.<init>(XPath.java:219)
      at org.apache.xalan.processor.StylesheetHandler.createMatchPatternXPath(StylesheetHandler.java:213)
      at org.apache.xalan.processor.XSLTAttributeDef.processPATTERN(XSLTAttributeDef.java:627)
      at org.apache.xalan.processor.XSLTAttributeDef.processValue(XSLTAttributeDef.java:926)
      at org.apache.xalan.processor.XSLTAttributeDef.setAttrValue(XSLTAttributeDef.java:1078)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:375)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:311)
      at org.apache.xalan.processor.ProcessorTemplateElem.startElement(ProcessorTemplateElem.java:122)
      at org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:656)
      at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:934)
      at BasicXsl.xsl(BasicXsl.java:18)
      at BasicXsl.main(BasicXsl.java:40)
---------
javax.xml.transform.TransformerException: Prefix must resolve to a namespace: a
      at org.apache.xalan.processor.XSLTAttributeDef.processPATTERN(XSLTAttributeDef.java:633)
      at org.apache.xalan.processor.XSLTAttributeDef.processValue(XSLTAttributeDef.java:926)
      at org.apache.xalan.processor.XSLTAttributeDef.setAttrValue(XSLTAttributeDef.java:1078)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:375)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:311)
      at org.apache.xalan.processor.ProcessorTemplateElem.startElement(ProcessorTemplateElem.java:122)
      at org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:656)
      at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:934)
      at BasicXsl.xsl(BasicXsl.java:18)
      at BasicXsl.main(BasicXsl.java:40)
---------
; Line#: 25; Column#: 34
; Line#: 25; Column#: 34
javax.xml.transform.TransformerException: Prefix must resolve to a namespace: a
      at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:602)
      at org.apache.xpath.compiler.Lexer.mapNSTokens(Lexer.java:674)
      at org.apache.xpath.compiler.Lexer.tokenize(Lexer.java:397)
      at org.apache.xpath.compiler.Lexer.tokenize(Lexer.java:139)
      at org.apache.xpath.compiler.XPathParser.initMatchPattern(XPathParser.java:193)
      at org.apache.xpath.XPath.<init>(XPath.java:219)
      at org.apache.xalan.processor.StylesheetHandler.createMatchPatternXPath(StylesheetHandler.java:213)
      at org.apache.xalan.processor.XSLTAttributeDef.processPATTERN(XSLTAttributeDef.java:627)
      at org.apache.xalan.processor.XSLTAttributeDef.processValue(XSLTAttributeDef.java:926)
      at org.apache.xalan.processor.XSLTAttributeDef.setAttrValue(XSLTAttributeDef.java:1078)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:375)
      at org.apache.xalan.processor.XSLTElementProcessor.setPropertiesFromAttributes(XSLTElementProcessor.java:311)
      at org.apache.xalan.processor.ProcessorTemplateElem.startElement(ProcessorTemplateElem.java:122)
      at org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:656)
      at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:934)
      at BasicXsl.xsl(BasicXsl.java:18)
      at BasicXsl.main(BasicXsl.java:40)

Got Following Exception
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 12490813
I got the above exception while working with following template

What is the problem in this template??



<?xml version="1.0" encoding="ISO-8859-1"?>
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   
<xsl:output method="text/html" indent="yes"/>

<xsl:template match="/">
    <html>
    <head>
          <style>
      TR { height: 20px; }
      TH { font-family: "Times New Roman"; font-size: 10pt; }
      TD { font-family: "Times New Roman"; font-size: 10pt; }
          </style>
    </head>
    <body>
    <div align="center">
        <h2>Email Information</h2>
                <xsl:apply-templates/>            
   </div>
    </body>
    </html>
</xsl:template>                

<xsl:template match="a:response">
    <table width="95%" border="1" cellspacing="0" cellpadding="3">
        <xsl:apply-templates/>
    </table>
    <br/>
</xsl:template>            

<xsl:template match="a:href">
    <tr valign="top">
     <td>
        Link:
    </td>
     <td>
        <xsl:value-of select="."/><br/>
    </td>
    </tr>
</xsl:template>

<xsl:template match="a:propstat">
    <xsl:apply-templates/>
</xsl:template>
<xsl:template match="a:status">
    <tr valign="top">
     <td>
        Status:
    </td>
     <td>
        <xsl:value-of select="."/><br/>
    </td>
    </tr>
</xsl:template>
<xsl:template match="a:prop">
      <xsl:apply-templates/>
</xsl:template>
<xsl:template match="d:hasattachment">
    <tr valign="top">
     <td>
        d:hasattachment
    </td>
     <td>
        <xsl:value-of select="."/><br/>
    </td>
    </tr>
</xsl:template>
<xsl:template match="e:message-id">
    <tr valign="top">
     <td>
        e:message-id
    </td>
     <td>
        <xsl:value-of select="."/><br/>
    </td>
    </tr>
</xsl:template>
<xsl:template match="e:date">
    <tr valign="top">
     <td>
        e:date
    </td>
     <td>
        <xsl:value-of select="."/><br/>
    </td>
    </tr>
</xsl:template>
<xsl:template match="e:from">
    <tr valign="top">
     <td>
        e:from
    </td>
     <td>
        <xsl:value-of select="."/><br/>
    </td>
    </tr>
</xsl:template>
<xsl:template match="e:to">
    <tr valign="top">
     <td>
        e:to
    </td>
     <td>
        <xsl:value-of select="."/><br/>
    </td>
    </tr>
</xsl:template>
<xsl:template match="e:to">
    <tr valign="top">
     <td>
        e:to
    </td>
     <td>
        <xsl:value-of select="."/><br/>
    </td>
    </tr>
</xsl:template>

</xsl:stylesheet>
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 12490817
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 12490827
I was executing the test application like this

java BasicXsl 1.xml 1.html 1.xsl
0
 
LVL 92

Assisted Solution

by:objects
objects earned 2000 total points
ID: 12491104
looks like u may need to define the a namespace
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 12491352
Where should i define??

That xml comes from Exchange server.

<a:multistatus xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:d="urn:schemas:httpmail:" xmlns:e="urn:schemas:mailheader:" xmlns:c="xml:" xmlns:a="DAV:">

xmlns:a="DAV:"  this is already there in a:multistatus


You mean I should define xsl file?? If so how??


0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 12491357
You mean I should define in xsl file?? If so how??
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 12491436
Yes

I was able to sove my problem


here is solution for namespace


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"  xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:d="urn:schemas:httpmail:" xmlns:e="urn:schemas:mailheader:" xmlns:c="xml:" xmlns:a="DAV:">
   
<xsl:output method="text/html" indent="yes"/>


thanks for helping me.



   
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses
Course of the Month5 days, 13 hours left to enroll

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question