Am Donnerstag, den 26.11.2009, 14:32 +0100 schrieb Jean-Yves F. Barbier:
> Doriano Blengino a écrit :
> ...
>
> Of that I'm aware Doriano, THE PB is I need each and every byte of the picture
> in order to cast it to a Base64 to send it to postgresql.
> Or just escape some chars, or whatever processing function I'll further need;
> because I know there are base64 functions in gb.xml (however totally
> undocumented)
> but what if I need to apply another process to a picture??...
>
> So it looks impossible, as each time I take a byte out from the string it is
> supposed to be an UTF8 one (so only 234 bytes are processed out of 298) AND
> I can't convert this string because Conv (& Conv$) fail as Bad string
> conversion...
>
> Now, if you have any clue, I'd be glad to ear about it.
>
> JY
Salut,
these three functions handle, the base64 function in gb.xml .
A picture is stored/extracted in/from an XML-file. I'v never compared
input / output, but the output-picture looked like the input.
I just copied out of the project, you have to strip it down yourself
to make it work.
The first ToXML calls somewhere the second ToXML for writing.
The *.xlst have nothing to do with the base64 stuff.
SUB ToXML(args AS String[]) '<--- calls 2nd ToXML
DIM xml AS NEW XmlWriter
DIM item AS Object
'xml.Open(args[0] & ".xml",TRUE,"utf-8")
xml.Open(modPath.FullPath(args[0]), TRUE, "utf-8")
xml.StartElement("P")
ToolBox.ToXML(xml, "*")
FOR EACH item IN ide.GeneralParams
item.ToXML(xml)
NEXT
Layout.ToXML(xml)
xml.EndElement() ' ("P")
xml.EndDocument()
$fname = modPath.RelativePath(args[0])
'ide.Push("LAYOUT.MODIFIED.CLEAR")
layout.Modified = 0
IF $QuitOnSave THEN ide.Push("REPORT.QUIT")
END
PUBLIC FUNCTION ToXML(xml AS XmlWriter) AS Object '<--- is calls by 1st
ToXML
DIM p AS Variant
DIM s AS String
DIM props AS Collection
props = ME.GetAll()
xml.StartElement("I")
FOR EACH p IN props
xml.Attribute(props.Key, p)
NEXT
'add image as base64
xml.Base64(file.Load(ME.ide.Logic.GetFile(ME.Get("Path"))))
xml.EndElement()
RETURN xml
END
'Translate XML to CMD's
SUB FromXML(args AS String[])
DIM Xml AS NEW XmlDocument
DIM Xsl AS NEW XmlDocument
DIM out AS XmlDocument
DIM Xr AS NEW XmlReader
DIM sString AS String
DIM sPath AS String
DIM htmlOut AS File
DIM sTmpFile AS String
IF Exist(modPath.FullPath(args[0])) THEN
Xml.FromString(modPath.FullPath(File.Load(args[0])))
IF Exist(application.Path &/ "xml/xml2file.xslt") THEN
Xsl.FromString(File.Load(application.Path &/ "xml/xml2file.xslt"))
out = XSLT.Transform(Xml, Xsl)
sTmpFile = Temp$()
out.Write(sTmpFile)
Xr.FromString(File.Load(sTmpFile))
WHILE NOT Xr.Eof
SELECT CASE Xr.Node.Type
CASE XmlReaderNodeType.Element
FOR EACH Xr.Node.Attributes
sPath = Xr.Node.Value
NEXT
CASE XmlReaderNodeType.Text
IF NOT $TempFile.Exist(sPath) THEN
$TempFile[sPath] = Temp()
file.Save($TempFile[sPath], Xr.Decode(Xr.Node.Value,
"base64"))
'PRINT "Temp: ";TempFile[sPath]
END IF
END SELECT
Xr.Read()
WEND
IF Exist(application.Path &/ "xml/xml2macro.xslt") THEN
Xsl.FromString(File.Load(application.Path &/
"xml/xml2macro.xslt"))
out = XSLT.Transform(Xml, Xsl)
sTmpFile = Temp$()
out.Write(sTmpFile)
sString = File.Load(sTmpFile)
'somes ent's not replaced, then replace them
'sString = Replace(sString," ","!")
sString = Replace(sString, "<", "<")
sString = Replace(sString, ">", ">")
sString = Replace(sString, "&", "&")
ide.Push(sString)
ide.Push("TOOLBOX.PARAMSET.INIT")
ide.Push("LAYOUT.SELECTION.REFRESH")
$fname = args[0]
ide.Push("LAYOUT.MODIFIED.CLEAR")
ELSE
message.Warning("can't find " & application.Path &/
"xml/xml2macro.xslt")
END IF
ELSE
message.Warning("can't find " & application.Path &/
"xml/xml2file.xslt")
END IF
ELSE
message.Warning("can't find " & args[0])
END IF
END
--
Amicalement
Charlie
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Gambas-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gambas-user