- From: Julian <cerebro70@yahoo.com>
- Date: Sat, 24 Feb 2007 08:44:12 -0800 (PST)
- To: helen_166 <helen_166@hotmail.com>, www-xsl-fo@w3.org, www-xsl-fo@w3.org
Helen,=0A=0AI think you need the xsl:template node to be a child node of th= e root node of the stylesheet for the XSLT engine to parse this document co= rrectly. For example:=0A=0A=0A xmlns:fo=3D"http://www.w3.org/1999/XSL/F= ormat">=0A <xsl:template match=3D"/" mode=3D"ffp">=0A <fo:= .....=0A <xsl:template>=0A</xsl:stylesheet>=0A=0AThen you can do your F= O inside the template or call a template that=0Awill generate the necessary= FO output. This is generally a good idea=0Afor FO that you will reference= many times in your stylesheet (e.g. the=0Amaster-reference for different p= ages or documents from one=0Astylesheet). =0Ahth,=0AJulian=0A=0A=0A----- Or= iginal Message ----=0AFrom: helen_166 <helen_166@hotmail.com>=0ATo: www-xsl= -fo@w3.org=0ASent: Friday, February 23, 2007 11:30:43 AM=0ASubject: xml to = xslfo using xslt doesnt work?=0A=0A=0Ai have a xml file which i need to tra= nsform to xslfo=0A=0Ai have created a java class to convert it but it doesn= t convert correctly,=0Awhen it converts the file the fo tags are completly = removed which isnt what=0Ai want can anyone tell me what im doing wrong=0A= =0Amy xslt: (part of)=0A<?xml version=3D"1.0" encoding=3D"iso-8859-1"?>=0A = =0A =0A <fo:root xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"= ;=0Axmlns:fo=3D"http://www.w3.org/1999/XSL/Format";=0Axmlns:saxon=3D"http:/= /icl.com/saxon";>=0A <fo:layout-master-set>=0A =0A = =0A <fo:simple-page-master master-name=3D"my-page">=0A = <fo:region-body margin=3D"0.75in"/>=0A </fo:simple-page-m= aster>=0A </fo:layout-master-set>=0A =0A <fo:page-sequenc= e master-reference=3D"my-page">=0A <fo:flow flow-name=3D"xsl-reg= ion-body">=0A =0A =0A =0A <xsl:templ= ate match=3D'/' mode=3D'ffp'>=0A =0A </xsl:templa= te>=0A =0A </fo:flow>=0A </fo:page-sequence>= =0A </fo:root>=0A=0A=0Athe java class:=0A public void CreateXSLFO= (String xmldocname, String xsltdocname, String=0Axslfodocname) {=0A = =0A System.out.println("creating xsl-fo");=0A =0A File= xmldocument =3D new File(xmldocname);=0A File xsltdocument =3D new = File(xsltdocname);=0A File xslfodocument =3D new File(xslfodocname);= =0A =0A try {=0A OutputStream outputstream = =3D new=0Ajava.io.FileOutputStream(xslfodocument);=0A =0A = TransformerFactory factory =3D TransformerFactory.newInstance();=0A = =0A //pass the xslt document=0A Transformer trans= former =3D factory.newTransformer(new=0AStreamSource(xsltdocument));=0A = =0A //pass the xml document=0A Source sourse =3D = new StreamSource(xmldocument);=0A =0A //pass the outp= utstream (new file)=0A Result result =3D new StreamResult(output= stream);=0A =0A // transform the xslt to xsl-fo using FOP=0A = transformer.transform(sourse, result);=0A } =0A catch= (Exception e)=0A {=0A e.printStackTrace();=0A }= =0A =0A System.out.println("xslfo created");=0A }=0A=0A=0A= -- View this message in context: http://www.nabble.com/xml-to-xslfo-using-xslt-doesnt-work--tf3279766.html#a9121929 Sent from the w3.org - www-xsl-fo mailing list archive at Nabble.com. ____________________________________________________________________________________ Don't get soaked. Take a quick peak at the forecast with the Yahoo! Search weather shortcut. http://tools.search.yahoo.com/shortcuts/#loc_weather --0-1436983439-1172335452=:3562 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable <html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt">Helen,<br><br>I think you need the xsl:template node to be a child node of the root node of the stylesheet for the XSLT engine to parse this document correctly. For example:<br><br><span><xsl:stylesheet xmlns:xsl="<a target='_blank' href='http://www.w3.org/1999/XSL/Transform'>http://www.w3.org/1999/XSL/Transform</a>" version="1.0"></xsl:stylesheet></span><br><span> xmlns:fo="<a target="_blank" href="http://www.w3.org/1999/XSL/Format">http://www.w3.org/1999/XSL/Format</a>"</span>><br> <xsl:template match="/" mode="ffp"><br> <fo: .....<br> <xsl:template><br></xsl:stylesheet><br><br>Then you can do your FO inside the template or call a template that will generate the necessary FO output. This is generally a good idea for FO that you will reference many times in your stylesheet (e.g. the master-reference for different pages or documents from one stylesheet). <br>hth,<br>Julian<br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: helen_166 <helen_166@hotmail.com><br>To: www-xsl-fo@w3.org<br>Sent: Friday, February 23, 2007 11:30:43 AM<br>Subject: xml to xslfo using xslt doesnt work?<br><br><div><br>i have a xml file which i need to transform to xslfo<br><br>i have created a java class to convert it but it doesnt convert correctly,<br>when it converts the file the fo tags are completly removed which isnt what<br>i want can anyone tell me what im doing wrong<br><br>my xslt: (part of)<br><?xml version="1.0" encoding="iso-8859-1"?><br> <br> <br> <fo:root xmlns:xsl="<a target="_blank" href="http://www.w3.org/1999/XSL/Transform%22">http://www.w3.org/1999/XSL/Transform"</a>;<br>xmlns:fo="<a target="_blank" href="http://www.w3.org/1999/XSL/Format%22">http://www..w3.org/1999/XSL/Format"</a>;<br>xmlns:saxon="<a target="_blank" href="http://icl.com/saxon%22">http://icl.com/saxon"</a>;><br> <fo:layout-master-set><br> <br> <br> <fo:simple-page-master master-name="my-page"><br> <fo:region-body margin="0.75in"/><br> </fo:simple-page-master><br> </fo:layout-master-set><br> <br> <fo:page-sequence master-reference="my-page"><br> <fo:flow flow-name="xsl-region-body"><br> <br> <br> <br> <xsl:template match='/' mode='ffp'><br> <br> </xsl:template><br> <br> </fo:flow><br> </fo:page-sequence><br> </fo:root><br><br><br>the java class:<br> public void CreateXSLFO(String xmldocname, String xsltdocname, String<br>xslfodocname) {<br> <br> System.out.println("creating xsl-fo");<br> <br> File xmldocument = new File(xmldocname);<br> File xsltdocument = new File(xsltdocname);<br> File xslfodocument = new File(xslfodocname); <br> <br> try {<br> OutputStream outputstream = new<br>java.io.FileOutputStream(xslfodocument);<br> <br> TransformerFactory factory = TransformerFactory.newInstance();<br> <br> //pass the xslt document<br> Transformer transformer = factory.newTransformer(new<br>StreamSource(xsltdocument));<br> <br> //pass the xml document<br> Source sourse = new StreamSource(xmldocument);<br> <br> //pass the outputstream (new file)<br> Result result = new StreamResult(outputstream);<br> <br> // transform the xslt to xsl-fo using FOP<br> transformer.transform(sourse, result);<br> } <br> catch (Exception e)<br> {<br> e.printStackTrace();<br> }<br> <br> System.out.println("xslfo created");<br> }<br><br><br>-- <br>View this message in context: <a target="_blank" href="http://www.nabble.com/xml-to-xslfo-using-xslt-doesnt-work--tf3279766.html#a9121929">http://www.nabble.com/xml-to-xslfo-using-xslt-doesnt-work--tf3279766.html#a9121929</a><br>Sent from the w3.org - www-xsl-fo mailing list archive at Nabble.com.<br><br><br><br></div></div><br></div></div><br> <hr size=1><a href="http://answers.yahoo.com/dir/index;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&sid=396545367">Food fight?</a> Enjoy some healthy debate<br>in the <a href="http://answers.yahoo.com/dir/index;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&sid=396545367">Yahoo! Answers Food & Drink Q&A.</a></body></html> --0-1436983439-1172335452=:3562--
Received on Saturday, 24 February 2007 18:04:06 UTC