473,651 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use output of XSL transformation as new XSL stylesheet

Hi,

I'm trying to pre-process an XSL stylesheet with another stylesheet,
before using the result to transform an XML document. i.e.:

stylesheet(xsl) --> preprocessor(xs l) --> temp(xsl)
input(xml) --> temp(xsl) --> output(xml)

but I'm getting a NullPointerExce ption. I'm not 100% sure exactly what
is going on here, so if someone could help I'd be grateful.

I've been working from the examples from Sun and Apache Xalan, and so
far have the following:

File input = new File("input.xml ");
File stylesheet = new File("styleshee t.xsl");
File preprocessor = new File("preproces s.xsl");

SAXTransformerF actory stf =
(SAXTransformer Factory)Transfo rmerFactory.new Instance();

// parse preprocessor stylesheet into templates handler
TemplatesHandle r tmpltHand = stf.newTemplate sHandler();
XMLReader reader = XMLReaderFactor y.createXMLRead er();
reader.setConte ntHandler(tmplt Hand);
reader.parse(ne w InputSource(new FileInputStream (preprocessor)) );

// create transformer handler based on templates handler
Templates templates = tmpltHand.getTe mplates();
TransformerHand ler transHand =
stf.newTransfor merHandler(temp lates);

// parse page stylesheet through proprocessor
reader.setConte ntHandler(trans Hand);
reader.setPrope rty("http://xml.org/sax/properties/lexical-handler",
transHand);

transHand.setRe sult(new StreamResult(Sy stem.out));
reader.parse(ne w InputSource(new FileInputStream (stylesheet)));

This all works fine, and displays the modified stylesheet. It's when I
try to use this stylesheet it all goes wrong. I thought I could just
redirect the output of the last stage, via a SAXResult. into a new
TemplatesConten tHandler, and then use this to transform the actual
input.

replace:
transHand.setRe sult(new StreamResult(Sy stem.out));

with:
TemplatesHandle r tmpltHand2 = stf.newTemplate sHandler();
transHand.setRe sult(new SAXResult(tmplt Hand2));

However, when I run this I get a NullPointerExce ption in
TransformerHand lerImpl.endDocu ment.

Can anybody see what is wrong here, or suggest a better way of doing
this?

Cheers,

Barney

Jan 16 '06 #1
0 1201

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2904
by: Bill Sneddon | last post by:
Can any one tell me how to output the following string? <%response.write "<tr><td><a href=""file://SERVER/mmlogs/TNAME" & yearmonth & """>"& "MYJUNK" & "</a><BR></td></tr>" %> <xsl:variable name="SERVER" select="MM_NAME" /> <xsl:variable name="TNAME" select="TOOL_NAME" />
0
2082
by: Dimitre Novatchev | last post by:
You seem to be unaware of the xslt processing which uses the built-in rules in the absence of templates that match some selected node. http://www.w3.org/TR/xslt#built-in-rule According to the XSLT processing model: http://www.w3.org/TR/xslt#section-Processing-Model the root node will be processed by a built-in rule, because you do not
3
3207
by: Ray Tayek | last post by:
hi, trying to use an xslt to make an xslt. trying something like: <?xml version="1.0" encoding="UTF-8"?> <?xmlspysamplexml H:\java\projects\spy1\spy\inputDocumentMap.xml?> <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"/> <xsl:template match="/inputDocumentMap"> <xsl:element name="xsl:template" match="/inputDocument">...
2
1552
by: Soren Kuula | last post by:
Hi, I'm trying to teach myself a little XSL. I have made up an XML model of a consed list, like : <list> <car>a</car> <cdr> <list> <car>b</car>
4
4725
by: Mike Conmackie | last post by:
Hi Folks, I've probably omitted something very basic but I have no idea what it might be. The results of my transformation _should_ be an xml file but all I get is the xml declaration immediately followed by the input node text values in one long string -- no xml tags (barring the xml declaration, of course) appear in the output file. Anyone who wants to see either the input xml file or the xsl file, please let me know and I will...
1
1504
by: KwiKiwi | last post by:
Hey, I'm doing a series of XSL Transformations from a C#.NET Console app. I've designed a .xsl file (to output to "text" not "xml") to generate a text file with entries that look like: "<OD:FO:"yes.gif",Picture,"C:\images\yes.gif">" I designed the .xsl file in Marrowsofts Xselerator application and when I
3
1527
by: Joseph A Romeo | last post by:
I have written an XSLT transformation on an ASP.NET page. The resulting HTML is primarily a table of links. I have found that when the resulting HTML is less than or equal to 16040 bytes, the output display is normal, but when the resulting HTML exceeds 16040 bytes, the output does not display correctly. When I look at View Source, I see that the final </html> tag gets moved to another spot in the output, byte by byte as I increase the...
3
1229
by: Fredy Muñoz [MCP] | last post by:
Hello there! I have a couple of questions about generating HTML using an XSLT Stylesheet. I use the System.Xml and System.Xml.Xsl namespaces and a XslTransform object to make the transformation, as follows: xsltTemplate.Transform(xmlOutput.CreateNavigator, Nothing, xmlWriter, Nothing)
18
3198
by: Terry Holland | last post by:
I have an asp.net (1.1) application that connects to a SQL server 2000 db. I have a stored procedure in my db that out puts data in xml format. What I need to be able to do is display that xml that I retrieve from my stored proc and display it in a web page formatted as I want. I have managed to get my xml to display as I wish if I manually run my stored proc in QA and copy the xml into notepad and save it as Test.xml. I reference my xsl...
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2699
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.