RE: FOP XML-XSLT-FOP PDF Issues

2008-12-22 Thread Patterson, Gregory Michael
Ok, I've started writing the actual xsl:fo style, and have a question for you 
guys.
The xml I'm using is below, so could you point me in the best direction to get 
to the field data of only the current='true' version? Thanks in advance.
documentContent
applicationContent
data edlName=Doc.Type.Name
version current=false date=Wed Dec 17 13:55:12 EST 
2008
version=0 /
version current=true date=Wed Dec 17 13:55:34 EST 
2008
version=1
field name=hiddenfirst
valueJoe/value
/field
field name=hiddenlast
valueSmith/value
/field
field name=hiddenUserId
value000112345/value
/field
field name=addr1
values/value
/field
field name=addr2
valueasd/value
/field
field name=phone
value999-888-/value
/field
field name=email
valuea...@this.net/value
/field
field name=uStatus
value01/value
/field
field name=responsetype
valueSuggestion/value
/field
field name=visitFreq
value01/value
/field
field name=referralBy
valueReferral/value
/field
field name=seen
value02/value
/field
field name=haveAppointment
valueYes/value
/field
field name=appointmentHow
valueIn Person/value
/field
field name=apptWhen
value /
/field
field name=providerName
value /
/field
field name=waitTime
valueNone/value
/field
field name=satisfied
valueNo/value
/field
field name=comment
valuesd/value
/field
field name=suggestion
valuesadf3/value
/field
/version
/data
/applicationContent
/documentContent

-Original Message-
From: Andreas Delmelle [mailto:andreas.delme...@telenet.be] 
Sent: Wednesday, December 17, 2008 2:23 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: FOP XML-XSLT-FOP PDF Issues

On 17 Dec 2008, at 20:01, Patterson, Gregory Michael wrote:

Hi

snip /

 I do have a question (it's simple I think): Looking at the example  
 xsl sheets, they utilize the xsl:fo funcationality and tags heavily,  
 but I thought that I was told (or read) somewhere that a regular  
 xslt stylsheet could be used as well. Is that the case, or will I  
 need write specially formatted xsl:fo styles for each form I need to  
 generate a pdf from? Thanks

Well, FOP is short for FO-Processor, so only deals with FO as input  
(an XML document in the XSL-FO namespace, adhering rules set out in  
the XSL-FO Recommendation). The XSLT specification grew out of XSL-FO,  
since there are many other use-cases for stylesheet transformations  
that have nothing to do with FO.
Most of these cases are XML-to-XML/HTML, so transforming the structure  
of a given source XML to yield a different one, or meant for a  
different output target. The most notable one is HTML or XHTML, but  
plain text is also a possibility. You could write a second stylesheet  
that transforms your XML into XHTML for alternate display in a web  
browser, if you'd like...
FOP

Re: FOP XML-XSLT-FOP PDF Issues

2008-12-22 Thread Andreas Delmelle

On 22 Dec 2008, at 18:21, Patterson, Gregory Michael wrote:

Hi Gregory,

Just a small FYI: this is a purely XSLT-related question, and we make  
it a policy of avoiding that type of question being asked on this forum.


In the future, please direct those questions to the Mulberry XSLT  
list, which is much better suited.


That said, no lack of XSLT knowledge among fop-users, so...

Ok, I've started writing the actual xsl:fo style, and have a  
question for you guys.
The xml I'm using is below, so could you point me in the best  
direction to get to the field data of only the current='true'  
version? Thanks in advance.

snip /

This, of course, depends on the context, but if you have something like:

xsl:template match=data.../xsl:template
or
xsl:for-each select=data.../xsl:for-each

Then inside that template/for-each, the pattern would be something like:

child::versi...@current='true']

More generally, starting from the root of the entire document, the  
XPath to select all those version-nodes in your case would be:


/*/*/data/versi...@current='true']


HTH!

Cheers

Andreas

-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



Re: FOP XML-XSLT-FOP PDF Issues

2008-12-22 Thread Andreas Delmelle

On 22 Dec 2008, at 18:35, Andreas Delmelle wrote:

Ok, I've started writing the actual xsl:fo style, and have a  
question for you guys.
The xml I'm using is below, so could you point me in the best  
direction to get to the field data of only the current='true'  
version? Thanks in advance.

snip /

snip /
Then inside that template/for-each, the pattern would be something  
like:


child::versi...@current='true']


Reading your question again, maybe this is slightly inaccurate, and  
you actually need:


child::versi...@current='true']/*

to select the child elements of the version-node.

Cheers

Andreas

-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



RE: FOP XML-XSLT-FOP PDF Issues

2008-12-18 Thread Patterson, Gregory Michael
Right, so currently I'm feeding the xml and an example style sheet in to the
FOP and it's working as expected. What I'm asking is, what forms can the 
Style sheet be in? I already have the xsl sheet like this for other purposes:

xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform; 
xmlns:my-class=xalan://edu.iu.uis.eden.edl.WorkflowFunctions version=1.0
xsl:include href=widgets /
xsl:output indent=yes method=html omit-xml-declaration=yes 
version=4.01 /
xsl:param name=overrideMain select='true' /
xsl:variable name=docStatus 
select=//documentState/workflowDocumentState/status /
.
.
.
xsl:template name=mainForm
  html xmlns=
head
  xsl:call-template name=htmlHead /
  style type=text/cssoption
  {
background-color: #ff;
color: #00;
  }/style
/head
body onload=onPageLoad()
  xsl:choose
xsl:when test=($isValidUser = 'true' or $isSuperUser = 
'true')
  xsl:call-template name=header /
  xsl:call-template name=errors /
  xsl:call-template name=footer /
  xsl:variable name=formTarget select='EDocLite' /
  form action={$formTarget} enctype=multipart/form-data 
id=edoclite method=post onsubmit=return validateOnSubmit(this)
xsl:call-template name=hidden-params /
xsl:call-template name=mainBody /
!-- No Notes for initiator --
xsl:if test=($docStatus != 'INITIATED') and 
not($isAtNodeInitiated)
.
.
.

And the style I'm currently using for the FOP is like this:
xsl:stylesheet version=1.1 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; 
xmlns:fo=http://www.w3.org/1999/XSL/Format; exclude-result-prefixes=fo
  xsl:output method=xml version=1.0 omit-xml-declaration=no 
indent=yes/
  xsl:param name=versionParam select='1.0'/ 
  !-- = --
  !-- root element: documentContent --
  !-- = --
  xsl:template match=documentContent
fo:root xmlns:fo=http://www.w3.org/1999/XSL/Format;
  fo:layout-master-set
fo:simple-page-master master-name=simpleA4 page-height=29.7cm 
page-width=21cm margin-top=2cm margin-bottom=2cm margin-left=2cm 
margin-right=2cm
  fo:region-body/
/fo:simple-page-master
  /fo:layout-master-set
  fo:page-sequence master-reference=simpleA4
fo:flow flow-name=xsl-region-body
  fo:block font-size=16pt font-weight=bold 
space-after=5mmProject: xsl:value-of select=projectname/
  /fo:block
.
.
.


So, do I need to re-write a stylesheet similar to the second one for each doc I 
need to convert to PDF 
Even if I have full stylesheets (like the first shown) already written out.
Thanks again.
-Greg

-Original Message-
From: Andreas Delmelle [mailto:andreas.delme...@telenet.be] 
Sent: Wednesday, December 17, 2008 2:23 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: FOP XML-XSLT-FOP PDF Issues

On 17 Dec 2008, at 20:01, Patterson, Gregory Michael wrote:

Hi

snip /
FOP offers the option to supply XML+XSLT as input, but this is more  
for users' convenience as the transformation from source XML to FO is  
taken care of by an XSLT processor (whichever one is available on the  
classpath).

To answer your question (if I get it correctly):
If you need PDF based on XML data, and you want to produce it using  
FOP, you'll indeed need to get familiar with both XSL-FO and XSLT. The  
benefit here is that you can use the same stylesheet for multiple  
output formats (PDF/PostSript/AFP/Java2D/RTF).


Cheers

Andreas
-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org

 

__ Information from ESET Smart Security, version of virus signature 
database 3699 (20081217) __

The message was checked by ESET Smart Security.

http://www.eset.com
 

-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



Re: FOP XML-XSLT-FOP PDF Issues

2008-12-18 Thread Andreas Delmelle


On 18 Dec 2008, at 23:45, Patterson, Gregory Michael wrote:

Right, so currently I'm feeding the xml and an example style sheet  
in to the
FOP and it's working as expected. What I'm asking is, what forms can  
the
Style sheet be in? I already have the xsl sheet like this for other  
purposes:

snip /

So, do I need to re-write a stylesheet similar to the second one for  
each doc I need to convert to PDF
Even if I have full stylesheets (like the first shown) already  
written out.

Thanks again.


Short answer: yes, if you want FOP to create the PDF.
The 'full' stylesheets you're referring to, they produce HTML+CSS  
which could obviously be converted to PDF in other ways (using  
Acrobat, for example).


If you were to produce XHTML, then there are stylesheets around to  
transform that into an XSL-FO document, but HTML+CSS is not XML so  
cannot be fed as input to an XSLT processor (nor FOP).




Cheers

Andreas

-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



RE: FOP XML-XSLT-FOP PDF Issues

2008-12-17 Thread Patterson, Gregory Michael
For reference, I finally got this resolved by using the approach below:
// configure fopFactory as desired
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired

// Setup output
OutputStream out =  response.getOutputStream();
  response.setContentType(application/pdf);

try {
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, 
foUserAgent, out);

// Setup XSLT
TransformerFactory factory = 
TransformerFactory.newInstance();
//Transformer transformer = factory.newTransformer(new 
DOMSource(getDocumentFromXMLString(xsltStyle)));
Transformer transformer = factory.newTransformer(new 
StreamSource(new StringReader(xsltStyle)));
//Transformer transformer = factory.newTransformer(new 
StreamSource(xsltStyle));

// Set the value of a param in the stylesheet
transformer.setParameter(versionParam, 0.9.1.3);

// Setup input for XSLT transformation
//Source src = new StreamSource(xmlfile);
Source src = new DOMSource(dom);

// Resulting SAX events (the generated FO) must be piped 
through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
//Result res = new StreamResult(System.out);

// Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
}

Thanks to everyone for their suggestions and help with this.
I do have a question (it's simple I think): Looking at the example xsl sheets, 
they utilize the xsl:fo funcationality and tags heavily, but I thought that I 
was told (or read) somewhere that a regular xslt stylsheet could be used as 
well. Is that the case, or will I need write specially formatted xsl:fo styles 
for each form I need to generate a pdf from? Thanks

-Greg

From: Griffin,Sean [mailto:sgrif...@cerner.com]
Sent: Tuesday, December 16, 2008 4:26 PM
To: fop-users@xmlgraphics.apache.org
Subject: RE: FOP XML-XSLT-FOP PDF Issues

Greg,
Can you show how you are calling into FOP?  Through the command-line or 
embedded in your Java app?  FOP can take either an XSL-FO document or an 
XML/XSLT document pair that generates the XSL-FO and then turns around and 
processes that FO.  While I'm guessing a bit here, this error seems like 
something that would happen if you were using the XSL-FO input example but 
passing in an XSLT stylesheet instead of an XSL-FO doc.

For example, to pass XML/XSLT into FOP do something like this (taken from the 
FOP examples):

TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new 
StreamSource(xsltfile));
Source src = new StreamSource(xmlfile);
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);

But to just pass in an FO doc:

TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
Source src = new StreamSource(fo);
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);

Something else to try is to just take FOP out of the equation and do a simple 
XSLT transformation.  You would expect an XSL-FO document as the result of the 
transformation, and if that doesn't happen then that would point you to why FOP 
is choking.

Sean

From: Patterson, Gregory Michael [mailto:grpat...@indiana.edu]
Sent: Tuesday, December 16, 2008 3:16 PM
To: fop-users@xmlgraphics.apache.org
Subject: FOP XML-XSLT-FOP PDF Issues

Hello,
I'm having some trouble getting the FOP to properly use an xslt stylesheet.
I am getting a ValidationException saying I need to put fo:root at the top.
My first element is an xsl element, but the first fo: element is
fo:root.  This is exactly the same format as the examples in the fop
examples packages.

In my case, I need to pull the appropriate xsl from a database, and
below is what I'm getting back:
?xml version=1.0 encoding=UTF-8?xsl:stylesheet 
xmlns:fo=http://www.w3.org/1999/XSL/Format; 
xmlns:xsl=http://www.w3.org/1999/XSL/Transform; exclude-result-prefixes=fo 
version=1.1
  xsl:output indent=yes method=xml omit-xml-declaration=no 
version=1.0/
  xsl:param name=versionParam select='1.0'/
  !-- = --
  !-- root element: projectteam --
  !-- = --
  xsl:template match=projectteam
fo:root xmlns:fo=http://www.w3.org/1999

Re: FOP XML-XSLT-FOP PDF Issues

2008-12-17 Thread Andreas Delmelle

On 17 Dec 2008, at 20:01, Patterson, Gregory Michael wrote:

Hi

snip /

I do have a question (it’s simple I think): Looking at the example  
xsl sheets, they utilize the xsl:fo funcationality and tags heavily,  
but I thought that I was told (or read) somewhere that a regular  
xslt stylsheet could be used as well. Is that the case, or will I  
need write specially formatted xsl:fo styles for each form I need to  
generate a pdf from? Thanks


Well, FOP is short for FO-Processor, so only deals with FO as input  
(an XML document in the XSL-FO namespace, adhering rules set out in  
the XSL-FO Recommendation). The XSLT specification grew out of XSL-FO,  
since there are many other use-cases for stylesheet transformations  
that have nothing to do with FO.
Most of these cases are XML-to-XML/HTML, so transforming the structure  
of a given source XML to yield a different one, or meant for a  
different output target. The most notable one is HTML or XHTML, but  
plain text is also a possibility. You could write a second stylesheet  
that transforms your XML into XHTML for alternate display in a web  
browser, if you'd like...
FOP offers the option to supply XML+XSLT as input, but this is more  
for users' convenience as the transformation from source XML to FO is  
taken care of by an XSLT processor (whichever one is available on the  
classpath).


To answer your question (if I get it correctly):
If you need PDF based on XML data, and you want to produce it using  
FOP, you'll indeed need to get familiar with both XSL-FO and XSLT. The  
benefit here is that you can use the same stylesheet for multiple  
output formats (PDF/PostSript/AFP/Java2D/RTF).



Cheers

Andreas
-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



RE: FOP XML-XSLT-FOP PDF Issues

2008-12-16 Thread Griffin,Sean
Greg,

Can you show how you are calling into FOP?  Through the command-line or 
embedded in your Java app?  FOP can take either an XSL-FO document or an 
XML/XSLT document pair that generates the XSL-FO and then turns around and 
processes that FO.  While I'm guessing a bit here, this error seems like 
something that would happen if you were using the XSL-FO input example but 
passing in an XSLT stylesheet instead of an XSL-FO doc.

 

For example, to pass XML/XSLT into FOP do something like this (taken from the 
FOP examples):

 

TransformerFactory factory = TransformerFactory.newInstance();

Transformer transformer = factory.newTransformer(new 
StreamSource(xsltfile));

Source src = new StreamSource(xmlfile);

Result res = new SAXResult(fop.getDefaultHandler());

transformer.transform(src, res);

 

But to just pass in an FO doc:

 

TransformerFactory factory = TransformerFactory.newInstance();

Transformer transformer = factory.newTransformer();

Source src = new StreamSource(fo);

Result res = new SAXResult(fop.getDefaultHandler());

transformer.transform(src, res);

 

Something else to try is to just take FOP out of the equation and do a simple 
XSLT transformation.  You would expect an XSL-FO document as the result of the 
transformation, and if that doesn't happen then that would point you to why FOP 
is choking.

 

Sean

 

From: Patterson, Gregory Michael [mailto:grpat...@indiana.edu] 
Sent: Tuesday, December 16, 2008 3:16 PM
To: fop-users@xmlgraphics.apache.org
Subject: FOP XML-XSLT-FOP PDF Issues

 

Hello,

I'm having some trouble getting the FOP to properly use an xslt stylesheet.

I am getting a ValidationException saying I need to put fo:root at the top.

My first element is an xsl element, but the first fo: element is

fo:root.  This is exactly the same format as the examples in the fop

examples packages.

 

In my case, I need to pull the appropriate xsl from a database, and 

below is what I'm getting back:

?xml version=1.0 encoding=UTF-8?xsl:stylesheet 
xmlns:fo=http://www.w3.org/1999/XSL/Format; 
xmlns:xsl=http://www.w3.org/1999/XSL/Transform; exclude-result-prefixes=fo 
version=1.1

  xsl:output indent=yes method=xml omit-xml-declaration=no 
version=1.0/

  xsl:param name=versionParam select='1.0'/ 

  !-- = --

  !-- root element: projectteam --

  !-- = --

  xsl:template match=projectteam

fo:root xmlns:fo=http://www.w3.org/1999/XSL/Format;

  fo:layout-master-set

.

.

.

 

 

 

Here is the error: 

(Location of error unknown)org.apache.fop.fo.ValidationException: Error: First 
element must be the fo:root formatting object. Found (Namespace URI: , Local 
Name: stylesheet) instead. Please make sure you're producing a valid XSL-FO 
document

Finished.

 

If you'll notice, the first fo element is fo:root, but I do have other things 
(required afaik) before it.

Thanks in advance for any help.

-Greg

--
CONFIDENTIALITY NOTICE This message and any included attachments are from 
Cerner Corporation and are intended only for the addressee. The information 
contained in this message is confidential and may constitute inside or 
non-public information under international, federal, or state securities laws. 
Unauthorized forwarding, printing, copying, distribution, or use of such 
information is strictly prohibited and may be unlawful. If you are not the 
addressee, please promptly delete this message and notify the sender of the 
delivery error by e-mail or you may call Cerner's corporate offices in Kansas 
City, Missouri, U.S.A at (+1) (816)221-1024.


RE: FOP XML-XSLT-FOP PDF Issues

2008-12-16 Thread Pete Allison
Are you handing this off directly to FOP or running it through another XSL
processor to produce the FO output?
 
I use the same structure in the stylesheet used to generate the FO output.
The XSL processor I have for my database doesn't speak FOP, so I use it to
generate an FO stylesheet that is handed off to FOP. Yes, it is a two-step
process.
 
The first element in my FO stylesheet (after the XML declaration) is
fo:root xmlns:fo=http://www.w3.org/1999/XSL/Format; xmlns:edit=edit.uri

My technique may not be the canonical method, but it works for me.
 
Pete Allison
Marshall Space Flight Center

The universal aptitude for ineptitude makes any human accomplishment an
incredible miracle. - Air Force Col. John P Stapp, first person to sustain
a 40g deceleration.

 
  _  

From: Patterson, Gregory Michael [mailto:grpat...@indiana.edu] 
Sent: Tuesday, December 16, 2008 3:16 PM
To: fop-users@xmlgraphics.apache.org
Subject: FOP XML-XSLT-FOP PDF Issues



Hello,

I'm having some trouble getting the FOP to properly use an xslt stylesheet.

I am getting a ValidationException saying I need to put fo:root at the top.

My first element is an xsl element, but the first fo: element is

fo:root.  This is exactly the same format as the examples in the fop

examples packages.

 

In my case, I need to pull the appropriate xsl from a database, and 

below is what I'm getting back:

?xml version=1.0 encoding=UTF-8?xsl:stylesheet
xmlns:fo=http://www.w3.org/1999/XSL/Format;
xmlns:xsl=http://www.w3.org/1999/XSL/Transform;
exclude-result-prefixes=fo version=1.1

  xsl:output indent=yes method=xml omit-xml-declaration=no
version=1.0/

  xsl:param name=versionParam select='1.0'/ 

  !-- = --

  !-- root element: projectteam --

  !-- = --

  xsl:template match=projectteam

fo:root xmlns:fo=http://www.w3.org/1999/XSL/Format;

  fo:layout-master-set

.

.

.

 

 

 

Here is the error: 

(Location of error unknown)org.apache.fop.fo.ValidationException: Error:
First element must be the fo:root formatting object. Found (Namespace URI:
, Local Name: stylesheet) instead. Please make sure you're producing a
valid XSL-FO document

Finished.

 

If you'll notice, the first fo element is fo:root, but I do have other
things (required afaik) before it.

Thanks in advance for any help.

-Greg



Re: FOP XML-XSLT-FOP PDF Issues

2008-12-16 Thread Jeremias Maerki
You need to remove exclude-result-prefixes=fo. I believe that causes
the problem.

On 16.12.2008 22:16:18 Patterson, Gregory Michael wrote:
 Hello,
 I'm having some trouble getting the FOP to properly use an xslt stylesheet.
 I am getting a ValidationException saying I need to put fo:root at the top.
 My first element is an xsl element, but the first fo: element is
 fo:root.  This is exactly the same format as the examples in the fop
 examples packages.
 
 In my case, I need to pull the appropriate xsl from a database, and
 below is what I'm getting back:
 ?xml version=1.0 encoding=UTF-8?xsl:stylesheet 
 xmlns:fo=http://www.w3.org/1999/XSL/Format; 
 xmlns:xsl=http://www.w3.org/1999/XSL/Transform; exclude-result-prefixes=fo 
 version=1.1
   xsl:output indent=yes method=xml omit-xml-declaration=no 
 version=1.0/
   xsl:param name=versionParam select='1.0'/
   !-- = --
   !-- root element: projectteam --
   !-- = --
   xsl:template match=projectteam
 fo:root xmlns:fo=http://www.w3.org/1999/XSL/Format;
   fo:layout-master-set
 .
 .
 .
 
 
 
 Here is the error:
 (Location of error unknown)org.apache.fop.fo.ValidationException: Error: 
 First element must be the fo:root formatting object. Found (Namespace URI: 
 , Local Name: stylesheet) instead. Please make sure you're producing a 
 valid XSL-FO document
 Finished.
 
 If you'll notice, the first fo element is fo:root, but I do have other things 
 (required afaik) before it.
 Thanks in advance for any help.
 -Greg




Jeremias Maerki


-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org



RE: FOP XML-XSLT-FOP PDF Issues

2008-12-16 Thread Patterson, Gregory Michael
Here's how I'm calling the FOP process. Prior to this, I have a db call to grab 
the stylesheet, and then I pass something like this: 
FOPConverter.createPDF(dom, styles, response) and the code below executes. I'm 
running the stylesheet from a db call right now, but still pulling the actual 
xml file from my local machine (trying to take it 1 step at a time =] ). If you 
need more, let me know.

public static void createPDF(Document dom, String xsltStyle, 
HttpServletResponse response) {
try {
// Setup directories
File baseDir = new 
File(C:/java/projects/rice/kew/src/main/java/edu/iu/uis/eden/edl/);

// Setup input and output files
File xmlfile = new File(baseDir, projectteam.xml);
//File xsltfile = new File(baseDir, projectteam2fo.xsl);

// configure fopFactory as desired
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired

// Setup output
OutputStream out =  response.getOutputStream();
  response.setContentType(application/pdf);

try {
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, 
foUserAgent, out);

// Setup XSLT
TransformerFactory factory = 
TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new 
DOMSource(getDocumentFromXMLString(xsltStyle)));
//Transformer transformer = factory.newTransformer(new 
StreamSource(xsltStyle));

// Set the value of a param in the stylesheet
transformer.setParameter(versionParam, 0.9.1.3);

// Setup input for XSLT transformation
Source src = new StreamSource(xmlfile);
//Source src = new DOMSource(dom);

// Resulting SAX events (the generated FO) must be piped 
through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);

where the 'getDocumentFromXMLString' method simply converts a string to a 
document object, if there's a better/easier way let me know.
Heres that method:
public static Document getDocumentFromXMLString(String xmlString) {
   try {
   DocumentBuilderFactory factory = 
DocumentBuilderFactory.newInstance();
   DocumentBuilder builder;
   builder = factory.newDocumentBuilder();
   Document document = builder.parse(new InputSource(new 
StringReader(xmlString)));
   return document;
   } catch (ParserConfigurationException e) {
   e.printStackTrace();
   return null;
   } catch (SAXException e) {
   e.printStackTrace();
   return null;
   } catch (IOException e) {
   e.printStackTrace();
   return null;
   }
}
From: Griffin,Sean [mailto:sgrif...@cerner.com]
Sent: Tuesday, December 16, 2008 4:26 PM
To: fop-users@xmlgraphics.apache.org
Subject: RE: FOP XML-XSLT-FOP PDF Issues

Greg,
Can you show how you are calling into FOP?  Through the command-line or 
embedded in your Java app?  FOP can take either an XSL-FO document or an 
XML/XSLT document pair that generates the XSL-FO and then turns around and 
processes that FO.  While I'm guessing a bit here, this error seems like 
something that would happen if you were using the XSL-FO input example but 
passing in an XSLT stylesheet instead of an XSL-FO doc.

For example, to pass XML/XSLT into FOP do something like this (taken from the 
FOP examples):

TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new 
StreamSource(xsltfile));
Source src = new StreamSource(xmlfile);
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);

But to just pass in an FO doc:

TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
Source src = new StreamSource(fo);
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);

Something else to try is to just take FOP out of the equation and do a simple 
XSLT transformation.  You would expect an XSL-FO document as the result of the 
transformation, and if that doesn't happen then that would point you to why FOP 
is choking.

Sean

From: Patterson, Gregory Michael [mailto:grpat...@indiana.edu]
Sent: Tuesday, December 16, 2008 3:16 PM
To: fop-users@xmlgraphics.apache.org
Subject: FOP XML-XSLT-FOP PDF

Re: FOP XML-XSLT-FOP PDF Issues

2008-12-16 Thread Andreas Delmelle

On 16 Dec 2008, at 22:35, Patterson, Gregory Michael wrote:

Hi

Here’s how I’m calling the FOP process. Prior to this, I have a db  
call to grab the stylesheet, and then I pass something like this:  
FOPConverter.createPDF(dom, styles, response) and the code below  
executes. I’m running the stylesheet from a db call right now, but  
still pulling the actual xml file from my local machine (trying to  
take it 1 step at a time =] ). If you need more, let me know.


snip /

Judging from the code, I can't see how that could lead to the earlier  
message:



Here is the error:
(Location of error unknown)org.apache.fop.fo.ValidationException:  
Error: First element must be the fo:root formatting object. Found  
(Namespace URI: , Local Name: stylesheet) instead.


This seems indicative of FOP being fed the stylesheet as its input,  
instead of the result of the transformation. Strange thing is that the  
XSLT namespace does not seem to be properly processed, which I'm  
assuming is somehow caused by the fact that you build up the  
stylesheet as a DOM (?)
Can you find out which XML parser and XSLT processor are used at  
runtime?


You could also try eliminating the DOM-approach from the picture. It  
seems slightly redundant, since you can easily set it up like:


transformerFactory.newTransformer(new StreamSource(new  
StringReader(xsltStyle)));


No need to construct a Document, if you don't absolutely need it for  
other purposes.





HTH!

Cheers

Andreas


-
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org