Re: xml to xslfo using xslt doesnt work?

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.&nbsp; For example:<br><br><span><xsl:stylesheet xmlns:xsl="&lt;a target='_blank' href='http://www.w3.org/1999/XSL/Transform'&gt;http://www.w3.org/1999/XSL/Transform&lt;/a&gt;" version="1.0"></xsl:stylesheet></span><br><span>&nbsp;&nbsp;&nbsp; xmlns:fo="<a target="_blank" href="http://www.w3.org/1999/XSL/Format">http://www.w3.org/1999/XSL/Format</a>"</span>&gt;<br>&nbsp;&nbsp;&nbsp; &lt;xsl:template match="/" mode="ffp"&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp;  &lt;fo: .....<br>&nbsp;&nbsp;&nbsp; &lt;xsl:template&gt;<br>&lt;/xsl:stylesheet&gt;<br><br>Then you can do your FO inside the template or call a template that
will generate the necessary FO output.&nbsp; 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 &lt;helen_166@hotmail.com&gt;<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>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;<br> <br>&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;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>;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;fo:layout-master-set&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;fo:simple-page-master master-name="my-page"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;fo:region-body margin="0.75in"/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/fo:simple-page-master&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/fo:layout-master-set&gt;<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;fo:page-sequence
 master-reference="my-page"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;fo:flow flow-name="xsl-region-body"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:template match='/'
 mode='ffp'&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsl:template&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/fo:flow&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/fo:page-sequence&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/fo:root&gt;<br><br><br>the java class:<br>&nbsp;&nbsp;&nbsp;&nbsp;public void CreateXSLFO(String xmldocname, String xsltdocname, String<br>xslfodocname) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("creating xsl-fo");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;File xmldocument = new
 File(xmldocname);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;File xsltdocument = new File(xsltdocname);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;File xslfodocument = new File(xslfodocname);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OutputStream outputstream = new<br>java.io.FileOutputStream(xslfodocument);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TransformerFactory factory = TransformerFactory.newInstance();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//pass the xslt document<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Transformer transformer =
 factory.newTransformer(new<br>StreamSource(xsltdocument));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//pass the xml document<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Source sourse = new StreamSource(xmldocument);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//pass the outputstream (new file)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result result = new StreamResult(outputstream);<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// transform the xslt to xsl-fo using FOP<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transformer.transform(sourse, result);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch
 (Exception e)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("xslfo created");<br>&nbsp;&nbsp;&nbsp;&nbsp;}<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