Re: [PHP] PHP with XML database

2007-01-26 Thread Bernhard Zwischenbrugger
Hi again

I don't know what the DB should do for you.

If you simple want to select subtrees from your big XML, you can put
the XML Files to the filesystem and use XPointer for query.

Here an example:

http://www.w3.org/2001/XInclude"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml";>
http://www.laptop.org/vision/index.shtml#xmlns(xhtml=http://www.w3.org/1999/xhtml)xpointer(//xhtml:div[1]//xhtml:div[1])"
 parse="xml">
   
   not found
   
  

END;

$dom=domDocument::loadXML($xml);
$dom->xinclude();

header("Content-type:text/xml");
echo $dom->saveXML();
?>

This example loads an XML (xhtml) from the web (filesystem is also
possible) and outputs a subtree of the document.
The subtree is selected by an XPointer expression.

The XML: http://www.laptop.org/vision/index.shtml
The XPointer:
"#xmlns(xhtml=http://www.w3.org/1999/xhtml)xpointer(//xhtml:div[1]//xhtml:div[1])"
(the namespace part is a little tricki)

To parse 100MByte takes some time.
A database can improve speed, the query syntax (XPointer) maybe is the
same.
Without knowing what the output of the database should be und the query
parameters, it is not easy to tell what db is the best for you.

A solution could be to split the 100MByte file in small parts and store
the subtrees to blobs in mySql. You can build an index based on XPath
and it could be a real fast solution.



Bernhard



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP with XML database

2007-01-26 Thread Bernhard Zwischenbrugger
Hi

Some questions

> As part of my research under my professor I have to implement a web 
> interface to their benchmarking data.
> 
> PHP is the chosen web language but we are little worried about the 
> database. The benchmark data comes to us in XML format (e.g. 
> http://www.matf.bg.ac.yu/~filip/ArgoLib/smt-lib-xml/Examples/FolEq1.xml).
> We have to implement an interface to query them, get data, update etc.

You can parse the XML, extract the data, put it to an SQL DB and move
the XML to /dev/null (delete it).
If you do that, you don't need an XML DB.
Is this possible?

> 
> We even can change schema in the form of attributes. . The data size 
> would be around 100 MB each XML with around 100 different XMLs.

What do you mean by "different XMLs"?
Are you looking for a maschine that makes SQL Tables from XML?
What is inside of the 100MB XML? Your example is a MathML Formula.

> 
> The load would be max 5-10 users any given time, batch updates once a 
> month and heavy load probably 2-3 times a month. Mission criticality is 
> not important, we can get it down sometimes. Which db would you suggest?
> 
> I did Google research and as of now - I like eXist, Sedna (they seem to 
> have good PHP wrapper support) and Timber. Another thing would be good 
> documentation and support.

With an XML DB you can query data using XPATH. Is that the thing you
want? Oracle supports that for example.

Bernhard

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parsing AJAX post data -- The Way

2007-01-25 Thread Bernhard Zwischenbrugger
hi

The "X" in AJAX says that the data are XML Data.

To parse XML I use DOM.
It is also possible to validate the data using RelaxNG, DTD or XMLSchema
before processing.

A receiver in PHP looks like

 use "php://input")
$content=file_get_contents("php://input");

//make a dom object
//many people know DOM already from programming javascript
$dom=domDocument::loadXML($content);

//validate with DTD,RelaxNG or XMLSchema
//http://at.php.net/manual/de/function.dom-domdocument-relaxngvalidate.php
if($dom->relaxNGValidate("test.rng")){

  //than read the data you need
  //for example if your XML looks like
  //
  //DaleiLama
  //

  $firstname=$dom->getElementsByTagName('firstname')->item(0);
  $lastname=$dom->getElementsByTagName('lastname')->item(0);
  $born=$dom->documentElement->getAttribute('born');
}else{
  echo "data are not valid";
}
?>



If you don't like XML (AJAX) use JSON.

Bernhard



Am Donnerstag, den 25.01.2007, 00:00 -0700 schrieb M5:
> Just wondering what smart people do for parsing data sent by the  
> Javascript XMLHTTP object--e.g., http.send("post",url,true)...
> 
> In a normal form submit, the $_POST global nicely allocates form  
> elements as array elements automatically. But with the AJAX way, the  
> data get stuffed inside $HTTP_RAW_POST_DATA as a string, thereby  
> making extraction more tedious.
> 
> Any ideas?
> 
> ...Rene
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] unzip openDocument in safe mode

2007-01-09 Thread Bernhard Zwischenbrugger
Am Dienstag, den 09.01.2007, 17:21 +0100 schrieb Jochem Maas:
> Bernhard Zwischenbrugger wrote:
> > I try to unzip openDocument files with pclzip.
> > At my laptop this is no big problem, but the target server has "safe
> > mode" switched on (no way to change that).
> > 
> > The problem with safe mode and unzipping openDocument ist, that a
> > openDocument zip file contains directories. It is not possible to write
> > to directory owned by webserver uid (because of safe mode)
> 
> are there no world writable directories available anywhere for you to use?

openDocuement looks like:
|-- Configurations2
|   `-- accelerator
|   `-- current.xml
|-- META-INF
|   `-- manifest.xml
|-- Thumbnails
|   `-- thumbnail.png
|-- content.xml
|-- meta.xml
|-- mimetype
|-- settings.xml
`-- styles.xml

The directories "Configurations2", "META-INF", "Thumnails" are created
and it is not possible for pclzip in safe mode to write to these
directories.


> 
> > 
> > My Project:
> > I try to extract the "content.xml" from openDocument, change it and
> > store it back to the openDocument (zip) file.
> > 
> > Question:
> > Is it possible to extract a single file from a zip file?
> > Is it possible to replace a single file in a zip file?
> 
> it kind of depends on your particular setup (server version, access to
> PECL, etc):
> 
> there is this (will require some reading to determine if you can
> use it in your case):
> 
>   http://php.net/zip

http://www.php.net/manual/de/function.ziparchive-addfile.php
and
http://at.php.net/manual/de/function.ziparchive-getfromname.php
would be fine.
If there is a package for BSD that would be a solution. 
Recompile PHP is no option.


> 
> and then there is the possibility of using exec() in conjunction with
> the cmdline zip utility, e.g.:
> 
>   $args = escapeshellarg($theRequiredArgsToZipCmd);
>   exec("zip -options $args");

Possibility, but not optimum.

> other than that all I can thing of is this (it might turn up something 
> usable):
> 
>   http://www.google.com/search?q=php+zip+file+class
> 
The only thing I found is pclzip and that makes problems

Bernhard
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] unzip openDocument in safe mode

2007-01-09 Thread Bernhard Zwischenbrugger
I try to unzip openDocument files with pclzip.
At my laptop this is no big problem, but the target server has "safe
mode" switched on (no way to change that).

The problem with safe mode and unzipping openDocument ist, that a
openDocument zip file contains directories. It is not possible to write
to directory owned by webserver uid (because of safe mode)

My Project:
I try to extract the "content.xml" from openDocument, change it and
store it back to the openDocument (zip) file.

Question:
Is it possible to extract a single file from a zip file?
Is it possible to replace a single file in a zip file?

I need something  like:

$contentString=extractFromZip("xy.zip","content.xml")
... $contentString will be changed ...
replaceFileInZip("xy.zip","content.xml",$contentString);


thanks

Bernhard

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Downloading utf-8 encoded files

2006-12-26 Thread Bernhard Zwischenbrugger
Hi

Try this:


There shouldn't be a character encoding problem with this two lines.

Don't forget the mime type:
http://earth.google.com/support/bin/answer.py?answer=25094&topic=1139

bernhard

Am Dienstag, den 26.12.2006, 17:22 +0500 schrieb Fahad Pervaiz:
> I want to download UTF-8 encoded kml files from a website. I have written a
> script that automatically downloads KML file. Problem is that some of the
> utf-8 charc are distrubed after saving file on windows. below is the script.
> 
> 
> .
> .
> .
> 
>$handle = fopen($link, "rb");
> 
>$handle2= fopen("kml/$i.kml","w");
> 
>$contents = '';
>while (!feof($handle)) {
>  $contents = fread($handle, 8192);
>  fwrite($handle2, $contents);
>}
>fclose($handle);
>fclose($handle2);
> .
> .
> .
> .
> 
> Also, there is another problem.Downloading file using the above script,
> downloads incomplete file, means some of the information is skipped and file
> size is also small.
> 
> Help would be appriciated
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Are PHP5 features worth it?

2006-12-21 Thread Bernhard Zwischenbrugger
Hi

You can make AJAX Applications without XML (AJWOX). You can also make
Synchronous AJAX without using the XMLHttpRequest Object.
You can call it SJWOX (synchronous javascript without XML).

The thing I like is, that character encoding is correct if you use XML
for sending data to the server. Wrong encoded messages are not accepted.

To make your own XML parser is not at all easy.
Think about a simple message like:


Ü is not Ü

(Parser must report an error)

Bernhard

Am Donnerstag, den 21.12.2006, 10:55 -0500 schrieb
[EMAIL PROTECTED]:
> Ha!  Mine too!   How long before this secret gets out and our apps all start 
> imploding??
> 
> Technically this is true.  You can't do AJAX with PHP4.  Or PHP5.  Not the 
> "AJAX" part at least, since it's all handled in Javascript.What gets 
> returned to the AJAX app and what it interacts with on the web server can 
> very well be PHP of any flavor, or any other web app scripting language or 
> even just regular HTML I suppose.
> 
> I love statements like Bernhard's.
> 
> -TG
> 
> = = = Original message = = =
> 
> At 3:14 PM +0100 12/20/06, Bernhard Zwischenbrugger wrote:
> >
> >"AJAX" Webapplications are not possible in PHP4.
> 
> Please be very, very quite, my PHP4 web "AJAX" Web applications don't 
> know that and I don't want them revolting.
> 
> tedd
> 
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
> 
> ___
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Are PHP5 features worth it?

2006-12-20 Thread Bernhard Zwischenbrugger
Is there a way to parse XML in PHP4?

The "X" in ajax means XML. If I send XML from Browser to PHP the XML
must be parsed.

In PHP4 there are "expat" functions and the experimental DOMXML
functions. Both are not included in default installations.

XML Support in PHP5 is realy good - in PHP4 nearly not existent.

Some peoply like JSON, I personaly prefer XML 


Bernhard

Am Mittwoch, den 20.12.2006, 06:47 -0800 schrieb Ray Hauge:
> PHP 5.2 supports JSON internally now, so you don't have to use XML.
> There's pros and cons associated with JSON, but that was possible with
> PHP4 as well.
> 
> --
> Ray Hauge
> Application Development Lead
> American Student Loan Services
> www.americanstudentloan.com
> 
> -Original Message-
> From: Stut [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 20, 2006 8:37 AM
> To: Robert Cummings
> Cc: Bernhard Zwischenbrugger; php-general@lists.php.net
> Subject: Re: [PHP] Are PHP5 features worth it?
> 
> Robert Cummings wrote:
> > On Wed, 2006-12-20 at 15:14 +0100, Bernhard Zwischenbrugger wrote:
> >> "AJAX" Webapplications are not possible in PHP4.
> > 
> > Bullshit.
> 
> Indeed, what with PHP being server-side and AJAX being client-side.
> 
> Where AJAX is concerned the server-side technology is irrelevant.
> 
> -Stut
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Are PHP5 features worth it?

2006-12-20 Thread Bernhard Zwischenbrugger
All the XML things are new

Start with DOM. If you know DOM in Browser you can use DOM in PHP5.
"AJAX" Webapplications are not possible in PHP4. The experimental DOMXML
in PHP4 is NOT standard conform and has DIFFERENT syntax than DOM in
Javascript.

To retrive data from AJAX is simple.

$data=file_get_contents('php://input');
$dom=domDocument::loadXML($data);

Using an iterator, it is easy to put this data to a database.

$elements=$dom->getElementsByTagName('whateveryouwant');
foreach($elements as $element){
...
}

XPath also helps a lot.
---
You can use and provide XML Comunication (Webservices) with the same
skills as you do  AJAX. Google for example has lots of Webservices that
are really useful. You can also connect to SAP Systems using XML for 
Data transfer...
This opens a new world.

And finally PHP5 has much better XSLT support than PHP4. It's still
experimental, but it uses libxslt which is a really good thing.
--
If you do real javascript programming (not only document.write and
innerHTML) there are lots of things you
can do in the same way in PHP5 and javascript.
Learn it once and use it Client- and Serverside - that's the good thing
in PHP5.

The bad thing is, that all this nice new things are hidden in the online
documentation. If you search for "getElementsByTagName" (a DOM Method)
you don't find it. The same with XSLT.

Bernhard

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DOMDocument Size limit

2006-12-19 Thread Bernhard Zwischenbrugger
Hi

> When calling |->createElement($name, $value) My content is truncated to 
> around 4k.  If what is in $value is less than 4000 bytes then it works 
> fine but if it is more, the data is truncated.  Is there a setting I 
> don't know about that will change that limit?  I need it to be more like 
> 100k or maybe even more.|

I can't see a 4k limit.
Here an example:

http://lamp2.fh-stpoelten.ac.at/%7Elbz/beispiele/ws2006/support/test.php
http://lamp2.fh-stpoelten.ac.at/%
7Elbz/beispiele/ws2006/support/test.phps

Maybe you use GET Variables, GET Variables are limited to 4k

Bernhard

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Byte order Mark (BOM, UTF-8, Header)

2006-12-06 Thread Bernhard Zwischenbrugger
The Problem:

If I edit a php file with Microsoft Notepad and save with UTF-8 encoding
there is a problem with headers.

example:
";
?>

PHP tells me, that the header is already set, because of the (invisible)
BOM http://de.wikipedia.org/wiki/Byte_Order_Mark

I teach php and 50% of my students have this problems if they use UTF-8
encoding (depends on editor).

My Question:

Is PHP UTF-8 ready?
Is there an other reason to stick on iso-8859-1 or ascii beside the BOM?
Is it a PHP bug, or is it a bug of the editor software?
 
thanks

Bernhard

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] alternative method

2006-12-02 Thread Bernhard Zwischenbrugger
Am Samstag, den 02.12.2006, 13:57 -0600 schrieb Larry Garfield:
> If you're talking about getting user data into a web script, then GET, POST, 
> and cookies are the only options.  All three are insecure, because they're 
> coming from the user.  The user is guilty until proven otherwise.  Sanitize 
> thy input.

There is also 
http://www.php.net/manual/en/features.http-auth.php
which may be more secure than POST.
With Client Side XSS  form data maybe can be read.
There is no access form javascript to http-auth parameters.

Bernhard

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Webbased Visual DOM Training Tool

2006-11-30 Thread Bernhard Zwischenbrugger
Hi
> >
> > http://test.datenkueche.com  (you need Firefox !!!)
> 
> I found it annoying that I couldn't break out of "demo1" by clicking
> on "demo2"

I have so many "setTimout" in javascript... but good point, I will
change that. Reload the page can be a workaround for now.

> 
> demo1 demo2 demo3 should probably change cursor or something to appear
> more "clickable"

done.

> 
> I didn't really understand what I was looking at, or why I'd want it
> or what I was supposed to learn from it...
> 

It's for learning DOM. There are the same commands in Javascript and PHP
(diffent syntax "." instand of "->").
It's very usefull for AJAX, Webservices,...

To start, here is a simple example:
http://www.khtml.org/guestbook/
http://www.khtml.org/guestbook/index.phps
(a guestbook)

> It looked very slick, but had an awful lot of repition of filling in
> some DOM field and clicking "do it".

That's DOM. There are only low level functions. The good thing is, that
you can do really a lot if you know about 10 DOM Methods. And the
methods are the same in Javascript !!!

> 
> I don't really need to see that more than a couple times to know I can
> fill in those fields and click "do it".
> 
> What I *do* need to know is what they heck to put in those boxes...
> bodylist
> listbody
> bodyList
> listBody
> I have no idea which of the above 4, if any, is the "right thing" to
> put in the box, and doubt that I'd figure it out any time soon...

bodylist, body, divElement,... are variable names. You can fill in what
you want. The "variables" are Objects. If you click on a variable (on
the right side) the object will be highlighted in the Tree.

"body" and "div" are tagNames - the names of HTML Elements.
Everything with a $ is a variable.


> 
> > There are also some "special" training files. The time you need to
> > finish an exercise will be stored in a "hi score" list.
> 
> I'm not sure I even figured out how to START an exercise, much less
> finish it...

choose "guestbook2", "guestbook3"

> 
> Maybe I'm just the village idiot, but I needed a bit more instruction
> on what the heck I was supposed to be doing...  Or maybe that's
> covered in a classroom somewhere.

If you never did something with DOM, this tool is not really useable
without more instructions. Maybe I will add a documentation. 
At the moment the starting point for learning is: 
http://www.php.net/dom

The first thing you need to know is what an "element", "attribute" and
"textNode" is. 

Simple_xml maybe is a little bit simpler then DOM, but DOM you can also
use in Javascript, Java, Python, Perl,... for HTML, SVG, MathML,...
Together with XSLT it is really powerfull.

> 
> It was definitely very slick though, whatever it was.
> 

Thank you. And thank you for testing and your comment!!!

Bernhard

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Webbased Visual DOM Training Tool

2006-11-30 Thread Bernhard Zwischenbrugger
Hi all

I made a web based visual Document Object Model (DOM) Training Tool for
my students:

http://test.datenkueche.com  (you need Firefox !!!)


Before I torture my students with this tools, I would like to have some
feedback from php mailinglist.

This tool should help to learn the DOM Object of PHP5
http://www.php.net/manual/de/ref.dom.php

There are 3 demos that shows you the functionality of the tool.

For interactive training there are some html/xml files in a drop down
list. You can also load files from http sources.

There are also some "special" training files. The time you need to
finish an exercise will be stored in a "hi score" list.

have fun, give feedback

Bernhard

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php