From 394f69e66bd32b21017fccb4cdd8df8036467e54 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 11 Apr 2010 18:45:59 +0200 Subject: [PATCH] Add doctype management. --- .../fr/devinsy/xid/FilePresenter.class | Bin 3347 -> 4100 bytes .../fr/devinsy/xid/StringPresenter.class | Bin 3397 -> 3550 bytes src/fr/devinsy/xid/FilePresenter.java | 50 +++++++++++++++--- src/fr/devinsy/xid/StringPresenter.java | 5 ++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/build/classes/fr/devinsy/xid/FilePresenter.class b/build/classes/fr/devinsy/xid/FilePresenter.class index ee698d81ceb4474dd799169dfd4cfdc87ea714cf..c8c2d2138ddb920db77d4481269716b299b59bee 100644 GIT binary patch literal 4100 zcma)9Ygbg)8Gg15%rHF)nFt9=$kIFB+RRy(DRqHW%YSr8T{*m9Etf`Py&&*ws&2`2}sCcb~&B4B)C4&OZC> z{XFmcyqCTC`+u%o2e2D|4P%``bJk5}th08$Fq=GYXOf5PoORT-3Rd2;+%Q54n=4lI zI#ZZ)9PFb8BIAxwS zlQ}a#ksR_|J3qmd8RtRUDv^P7=w@6PqXXkD29)+sbwh@KUK__EHQIA*{ zH!0k*h7AU8#zuwO3Cr`1QrOX2#(ywp77E>MYr0Sig+>F_s8OgJu=Cd7%+$E$4x8gS z?TM2%b0el}%X=_c)1wWIq6(W0G-179+-4w*h>UJGP>ZOHwix&bW;fiGY$bB0mv&lF_lz-&KlX`#&(%gerZN2y|u zfnC_AuxEwYHE$dU0=R@&=s8wq2WX`-F59o-nB7(!nJ$LO11r@rlZ$BSpIEXyJz;9~}k z3wX8Vx{ez~C;DXLNdsTQgLKI{Zx=jD#|l0kfvIpuIamM`AD{8!0-SYb@|k#R1S}5K zCP0>fEGB3gi`Gjy89QrRREThgqp)#0j8h7?RwO{FWf{m}irFWs4?DxI#R5*ODz5aB z6@@6t;~1F68DcQ;SfPGv+O{f2WePAd^qhStZ@H%DFc)Un-$wg;JHShD}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gO2shtoIgtRhdVIT*ZH2-2%iY`|@^wtC+=|^6IN~ z1#S@FCVjc(#uWCH+#;4O?|IGnM(@61bFOjCeY?z@Mm^aeC36F9EXq4xI=o`{%-tox zJp$i%&BZ*WqB*J;Yje@CH0K$vsyoVl{*Ls@VI})kR=7Vli|;GTo*ztnB|AglM|XGk Ee`=EEw*UYD diff --git a/build/classes/fr/devinsy/xid/StringPresenter.class b/build/classes/fr/devinsy/xid/StringPresenter.class index 8dd411fb3b49d9b958e8d4ab63afbd81a66349e9..ec785cdb8953438acabe0971631642d08c071efe 100644 GIT binary patch delta 800 zcmZ9JTS!z<6o$V&&Y3fF=Hv|(M~xIQyd+XYrG?asG@wP)g9U+x7pBB)X1rz7SY~B+ z+fAie&{NP;VN6*dK}66?(QDvqj}bu-NVd)yi|FC3^RIvXd#$zq{kCMO)O!ExTtNG^=Ri% zXG33Se{aKnm)~yD!HCT$6$)cG8i{vX^fG3%o>RKdX!V`8Niwb%je6f%n+eY8Z$^vv zyfoAwjUvCrBw#x4xVTyH48`?MlI4V4VUDMXr5Sd}P~8ho)~87{c|+cJ_*L5@4(M{L zK`&XssxwVS$XI39ykhcT$av0$whd3jxGV}J9;HNQ2Wyg3a>*1C9&?O&`dFZ!MFx07 zln=!COq?%b;&+Dm$(VwKGDs?m301&F3Z>ToLFXc@qg*lvZI+7Swaltw3J*X2AZ7kV z1;SS)-SQ40FX5NiPW~!NFvDf82)Dptu8Php!wa}3I)m#nr=8$dbA@8OCerr?ro1>S zyPXpT%PRbm%oED{^U3gxCR8Ia!1_D i%H2gJcV&<`DmCSfG-}h#{J)2yFjq7l`4snDH1`{~Q3@i(bElfkd!F}s&N`f4WZb-aGUODerQr5EXDr%ez1@~bQj&T1firE9k=J%chP{E{ zdR#tZF(4yer+l`vV);4i_Om{JmmPHD;HukCnM{_We9v>zy)PNdFEAmwRDX7Ahe?}v z_*UUD(GsNtY4d`!h1|T>Bxu$5Fl%Hk)m@oph$=^zWrTZ-@`z(RVT?tJyk&wso0+lY}6Q|t(374?Vr^=n-2~2y@6Jg|Eum)u7Y3Du%DI~Dk^i7 z^IT9=&8mqAX5&G%HG}J*)2WOM{MYE>X z2>xrzdkm)Pva(%Vm2Y83%eDAKcKt-It^-vGqYi6E`t-dad!zPXPSfwx#6ua6(wpO@ mn;L5cI%!o;l4#ydCpT4#&y>{|_cA>T+>)heop-11GW!QTD{L$P diff --git a/src/fr/devinsy/xid/FilePresenter.java b/src/fr/devinsy/xid/FilePresenter.java index d748307..f801c4d 100644 --- a/src/fr/devinsy/xid/FilePresenter.java +++ b/src/fr/devinsy/xid/FilePresenter.java @@ -1,7 +1,7 @@ package fr.devinsy.xid; import java.io.*; -import org.w3c.dom.*; + /** @@ -17,6 +17,7 @@ public class FilePresenter extends DomPresenter protected String sourceFilePathname; protected long sourceFileTime; + protected String doctype; /* * @@ -26,6 +27,7 @@ public class FilePresenter extends DomPresenter this.sourceFilePathname = null; this.sourceFileTime = 0; this.doc = null; + this.doctype = ""; } @@ -37,6 +39,7 @@ public class FilePresenter extends DomPresenter this.sourceFilePathname = filePathname; this.sourceFileTime = 0; this.doc = null; + this.doctype = ""; } @@ -48,6 +51,7 @@ public class FilePresenter extends DomPresenter this.sourceFilePathname = filePathname; this.sourceFileTime = 0; this.doc = null; + this.doctype = ""; } @@ -81,10 +85,10 @@ public class FilePresenter extends DomPresenter { StringBuffer result; - String sourceFilePath = this.sourceFilePathname; - + logger.info("doXid for file [" + this.sourceFilePathname + "]"); + // Get the good tree. - File source = new File (sourceFilePath); + File source = new File (this.sourceFilePathname); if (source == null) { @@ -95,17 +99,17 @@ public class FilePresenter extends DomPresenter } else if (!source.exists ()) { - String errorMessage = "source file defined but not found (" + sourceFilePath + ")"; + String errorMessage = "source file defined but not found (" + this.sourceFilePathname + ")"; logger.error (errorMessage); result = null; throw new Exception (errorMessage); } else if ((this.doc == null) || - (this.sourceFileTime != source.lastModified ())) + (this.sourceFileTime != source.lastModified ())) { this.sourceFileTime = source.lastModified (); - this.doc = Presenter.fileToTree (sourceFilePath); - + this.doc = Presenter.fileToTree (this.sourceFilePathname); + this.doctype = getDoctype(this.sourceFilePathname); if (this.doc != null) { Presenter.addMetaTag (doc, "generator", "XID 0.0"); @@ -114,6 +118,9 @@ public class FilePresenter extends DomPresenter // Build the web page. StringWriter htmlCode = new StringWriter(Presenter.estimatedTargetLength(source.length())); + htmlCode.write(doctype); + htmlCode.write('\n'); + Presenter.doXid (htmlCode, doc, datas); result = htmlCode.getBuffer(); @@ -122,6 +129,33 @@ public class FilePresenter extends DomPresenter } + static public String getDoctype (String filePathname) throws Exception + { + String result; + + // + BufferedReader in = new BufferedReader (new FileReader (filePathname)); + String doctype = in.readLine(); + in.close(); + + logger.info("doctype=[" + doctype + "]"); + + // + if ((doctype.startsWith ("'))); + } Presenter.doXid (htmlCode, doc, datas); StringBuffer htmlTarget = htmlCode.getBuffer();