Hi,
This is the first time I use SAX in order to translate my XML and I
encountered the following problem.
I use the following Java-code to produce xml that should be transformed
(Based on the xml that is created by the 'createXml()' several
underlying xml-files are merged together. The resulting xml seems to be
well-formed):
When I use the xsl-file, only the root element is transformed, resulting
in the output at the end of this message (blank lines are deleted).
Why are all the other elements ignored (If I write the xml and xsl to my
file-system and use Internet Exlorer to view the xml, the xml -s
transtlated as intended)?
Ben
public class XMLtoPDFtrans {
private Reader inputXml = null;
private String inputXsl;
private String blockDefLocatio n;
private SAXTransformerF actory saxTransFact;
private TransformerHand ler transHand;
static Document document;
private TransformerFact ory tf;
public XMLtoPDFtrans(S tring formName,
String[] formBlocks,
String formBlockDefLoc ation) {
if (formName == null || formBlocks ==null) {
System.out.prin tln("Onvoldoend e input");
System.exit(1);
}
blockDefLocatio n = formBlockDefLoc ation;
inputXml = createXml(formN ame, formBlocks);
tf = TransformerFact ory.newInstance ();
try {
// inputXsl = new
File("WEB-INF\\src\\minln v\\pdf\\XML_to_ PDF.xsl").toURL ().toExternalFo rm();
if (tf.getFeature( SAXTransformerF actory.FEATURE) ) {
saxTransFact = (SAXTransformer Factory) tf;
transHand = null;
if (inputXsl == null) {
transHand = saxTransFact.ne wTransformerHan dler();
} else {
transHand = saxTransFact.ne wTransformerHan dler(
new StreamSource(in putXsl));
}
}
transHand.setRe sult( new StreamResult(Sy stem.out));
} catch (TransformerCon figurationExcep tion e) {
e.printStackTra ce();
// } catch (MalformedURLEx ception e) {
e.printStackTra ce();
}
}
public StreamResult getStream() {
StreamResult result = null;
try {
InputSource xmlInputFile = new InputSource( inputXml);
SAXFormLezer saxFormLezer = new SAXFormLezer( blockDefLocatio n);
saxFormLezer.se tContentHandler (transHand);
saxFormLezer.pa rse(xmlInputFil e);
} catch (FileNotFoundEx ception e) {
e.printStackTra ce();
} catch (IOException e) {
e.printStackTra ce();
} catch (SAXException e) {
e.printStackTra ce();
}
return result;
}
private Reader createXml(Strin g form, String[] blocks) {
CharArrayWriter caw = new CharArrayWriter ();
String opbouw = form;
AttributesImpl attribImpl = new AttributesImpl( );
attribImpl.addA ttribute("","bo ttomMargin","bo ttomMargin","fl oat","50.0");
attribImpl.addA ttribute("","le ftMargin","left Margin","float" ,"20.0");
attribImpl.addA ttribute("","pa geHeight","page Height","float" ,"650.0");
attribImpl.addA ttribute("","pa geWidth","pageW idth","float"," 300.0");
try {
DataWriter w = new DataWriter(caw) ;
w.startDocument ();
w.startElement( "","formulier", "formulier",att ribImpl);
for (int tel = 0; tel <blocks.lengt h; tel++) {
attribImpl = new AttributesImpl( );
attribImpl.addA ttribute("","na am","naam","Str ing",blocks[tel]);
opbouw += blocks[ tel];
w.dataElement(" ","formBlock"," formBlock", attribImpl,"");
}
w.dataElement(" formClassName", opbouw);
w.endElement("" ,"formulier","f ormulier");
w.endDocument() ;
} catch (SAXException e) {
e.printStackTra ce();
}
return new CharArrayReader (caw.toCharArra y());
}
Produced xml:
_____________
<?xml version="1.0" encoding="UTF-8"?><interim >
<formBlock blockHeight="65 0.0" blockName="A01" >
<pageSeparator> true</pageSeparator>
<dataItemStri ng posY="640.0" posX="202.0" substringBegin= "2"
substringEnd="4 ">
<dataItem>
<dataId>1</dataId>
</dataItem>
</dataItemString>
<dataItemStri ng posY="640.0" posX="257.0" substringBegin= "2"
substringEnd="4 ">
<dataItem>
<dataId>71</dataId>
</dataItem>
</dataItemString>
<dataItemStri ng posY="640.0" posX="312.0">
<dataItem>
<dataId>81</dataId>
</dataItem>
</dataItemString>
</formBlock>
<formClassName> eGDIA01</formClassName>
</interim>
xsl
____
<?xml version="1.0"?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" />
<xsl:template match="formClas sName" >
formClassName
<xsl:apply-templates />
</xsl:template>
<xsl:template match="/">
DataItem
<xsl:apply-templates />
</xsl:template>
<xsl:template match="//pageSeparator" >
PageSep
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>
Output:
_________
DataItem
true
1
71
81
eGDIA01 0 965 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jayaprakash Rudraraju |
last post by:
Hi,
All php files in document root work fine. While php
files in sub-directories of document root shows the
php source like a text file.
I have looked for help and also FAQ. Did I miss anything
during the installation. I have installed both apache and
php on Linux many times before actually figuring out that
all my php files generate html only in document root.
|
by: Krzysztof Kaczkowski |
last post by:
Hello
Im having problem, wxTreeCtrl generate 3 x EVT_TREE_SEL_CHANGED on click
item right button mouse. This problem only win32. Why?
Simple example:
from wxPython.wx import *
class MyApp(wxApp):
def OnInit(self):
|
by: Nicolas Favre-Félix |
last post by:
Hello,
I have a little problem using Tkinter:
I'd like to make a interface with 3 labels on the left, facing with 3 Entry
on the right, a button below Entrys, and a Listbox under all. I could place
the Labels and Entrys, but the Listbox is just in column 0, and I want it to
take all the width (column 0 + column 1)
here is the code:
#########################
|
by: pauline_neave |
last post by:
Hi-ya,
I want to be able to only allow root access while I dump the databases,
thus locking out all non-root users ( even remote logins) then allow
all normal users back in after the dump has been done.
How would I go about this please.
thanz..
Pauline...
|
by: news.sbcglobal.net |
last post by:
I hope I can explain this well enough to understand. I have a master page
that is used by almost all of the pages in my site. On the master page is a
table. In one of the cells in this table, I have set the background to
display an image that is located in a directory called "images" which is
just off the root directory. Here's the problem:
Any page that is not located in the root directory (where the master page is
located) cannot...
| |
by: Fabrizio Pollastri |
last post by:
My code is the following:
from Tkinter import *
def tk_dummy_call(*args):
return
root = Tk()
# save call address
|
by: mp- |
last post by:
I want to be able to allow people to check their email from my PHP
online application.
Given only the users 1) email address, 2) username (if applicable) and
3) password - how can I auto detect a remote IMAP/POP3 server so that
I can connect and fetch mail for the user. (Ultimately, I don't want
users to have to know what the IMAP/POP3 server name / port is .... I
would like to auto-detect all of that).
At first I thought I could use...
|
by: martinnorth |
last post by:
Hi,
I am running Python and MySQL on Ubuntu and have installed MySQLdb. If I
try to import MySQLdb I get the following error:
ActivePython 2.5.2.2 (ActiveState Software Inc.) based on
Python 2.5.2 (r252:60911, Mar 27 2008, 16:42:08)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
|
by: jmDesktop |
last post by:
I have searched everywhere and tried several things. I have a
treeview with and want to be able to only select a parent node. For
example:
root //don't want to drag this
-parent1 //yes, drag this an only this because it is a parent
--childOfParent1 //cannot drag this, only the parent
--childOfParent1 //can only drag parent
-parent2 //yes, parent, can select and drag
--childOfParent2 //no, cannot drag
|
by: Amichai |
last post by:
Hi All.
I have an xml something like this:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<person>
<name>John</name>
<family name>Smith</family name>
</person>
|
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...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |