Re: Is std.xml seriously broken, or is it me?

2017-07-31 Thread Kagamin via Digitalmars-d-learn

On Sunday, 30 July 2017 at 03:16:35 UTC, Mike wrote:

It appears `onStartTag` does not handle the root element.


Looks like a bug. Until the module is replaced, bug reports are 
still accepted for it.


Re: Is std.xml seriously broken, or is it me?

2017-07-30 Thread Joakim via Digitalmars-d-learn

On Sunday, 30 July 2017 at 03:16:35 UTC, Mike wrote:

On Sunday, 30 July 2017 at 02:58:09 UTC, Mike wrote:


[...]


It appears `onStartTag` does not handle the root element.  For 
example, this code seems to work:


import std.xml;
import std.stdio;

void main()
{
	auto parser = new DocumentParser("encoding=\"utf-8\"?>");

parser.onStartTag["peripheral"] = (ElementParser parser)
{
writeln("peripheral");
};
parser.parse(); 
}

Mike


You may want to try the experimental candidate for Phobos 
instead, which was developed as a GSoC project but never finished:


http://code.dlang.org/packages/std-experimental-xml


Re: Is std.xml seriously broken, or is it me?

2017-07-29 Thread Mike via Digitalmars-d-learn

On Sunday, 30 July 2017 at 02:58:09 UTC, Mike wrote:


import std.xml;
import std.stdio;

void main()
{
	auto parser = new DocumentParser("encoding=\"utf-8\"?>");

parser.onStartTag["device"] = (ElementParser parser)
{
writeln("device");
};
parser.parse(); 
}

https://dpaste.dzfl.pl/262597d2fda6

I used it before without any trouble.  Is it somehow seriously 
broken?  If not, what am I doing wrong?


It appears `onStartTag` does not handle the root element.  For 
example, this code seems to work:


import std.xml;
import std.stdio;

void main()
{
	auto parser = new DocumentParser("encoding=\"utf-8\"?>");

parser.onStartTag["peripheral"] = (ElementParser parser)
{
writeln("peripheral");
};
parser.parse(); 
}

Mike



Is std.xml seriously broken, or is it me?

2017-07-29 Thread Mike via Digitalmars-d-learn

I'm trying to use std.xml, and I can't get it to work.

I tried the simplest program I could think of:

import std.xml;
import std.stdio;

void main()
{
	auto parser = new DocumentParser("encoding=\"utf-8\"?>");

parser.onStartTag["device"] = (ElementParser parser)
{
writeln("device");
};
parser.parse(); 
}

https://dpaste.dzfl.pl/262597d2fda6

I used it before without any trouble.  Is it somehow seriously 
broken?  If not, what am I doing wrong?


Thanks,
Mike


Re: Faster alternatives to std.xml

2017-07-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 8, 2017 8:45:57 PM MDT Nordlöw via Digitalmars-d-learn 
wrote:
> What's the fastest XML-parser on code.dlang.org?
>
> Are there any benchmarks that show performance improvements
> compared to std.xml?

I'm not aware of any benchmarks for std.xml, but from what I know of it, it
would likely lose them all.

I've used

http://code.dlang.org/packages/std-experimental-xml

which was a GSoC project last year and was aimed at becoming the new
std.xml, but it hasn't been touched since November. It seems like the author
got too busy with school, and it fell completely by the wayside. So, I don't
know what's going to happen to it. It's worked reasonably well for my needs,
but it does have bugs, and it needs some work. I'd still rather use it than
std.xml though.

- Jonathan M Davis




Faster alternatives to std.xml

2017-07-08 Thread Nordlöw via Digitalmars-d-learn

What's the fastest XML-parser on code.dlang.org?

Are there any benchmarks that show performance improvements 
compared to std.xml?


Re: std.xml

2014-01-14 Thread Ola Fosheim Grøstad

On Monday, 13 January 2014 at 19:54:22 UTC, Jacob Carlborg wrote:
I'm not sure what you're trying to do but the implementation in 
Tango uses structs for the nodes so you cannot subclass that.


I want to read XML files and replace the nodes I care about 
(shapes and transforms) with my own version so that I more easily 
can manipulate it (using a more efficient internal 
representation). The kxml library appears have a node class, so 
maybe that is the better option.


Re: std.xml

2014-01-14 Thread Jacob Carlborg
On 2014-01-14 09:57, Ola Fosheim Grøstad 
ola.fosheim.grostad+dl...@gmail.com wrote:



I want to read XML files and replace the nodes I care about (shapes and
transforms) with my own version so that I more easily can manipulate it
(using a more efficient internal representation). The kxml library
appears have a node class, so maybe that is the better option.


The Tango XML parser is one of the fastest XML parser available:

http://dotnot.org/blog/archives/2008/03/10/xml-benchmarks-updated-graphs-with-rapidxml/

--
/Jacob Carlborg


Re: std.xml

2014-01-13 Thread Ola Fosheim Grøstad

Thanks Jacob and Dejan!

I guess I can just build a generic DOM using one of those and 
replace the nodes I am interested with subclasses after the tree 
building process. I was thinking more of a library that allows me 
to say that a specific element (like svg) should use a specific 
subclass, but mapping after building is ok too I suppose.


Re: std.xml

2014-01-13 Thread Jacob Carlborg
On 2014-01-13 18:47, Ola Fosheim Grøstad 
ola.fosheim.grostad+dl...@gmail.com wrote:

Thanks Jacob and Dejan!

I guess I can just build a generic DOM using one of those and replace
the nodes I am interested with subclasses after the tree building
process. I was thinking more of a library that allows me to say that a
specific element (like svg) should use a specific subclass, but
mapping after building is ok too I suppose.


I'm not sure what you're trying to do but the implementation in Tango 
uses structs for the nodes so you cannot subclass that.


--
/Jacob Carlborg


Re: std.xml

2014-01-10 Thread Dejan Lekic
On Friday, 10 January 2014 at 00:02:14 UTC, Ola Fosheim Grøstad 
wrote:
The std.xml documentation states This module is considered 
out-dated and not up to Phobos' current standards.


Does this mean that there is some other module I should use for 
xml parsing? Maybe one that is not in the standard distribution 
yet because it is beta?


I'd like to convert a xml-based tool I have written in another 
language to D as an experiment, but I'd like to use libraries 
that are likely to stay up to date.


Bascally it entails:
- reading a xml file
- build a dom for it
- optimize it
- write it back to another xml file

What options do I have in terms of actively maintained 
libraries that are suitable for this kind of utility? Beta 
quality is ok.


Here is one of the alternatives: 
https://github.com/opticron/kxml/blob/master/source/kxml/xml.d


std.xml

2014-01-09 Thread Ola Fosheim Grøstad
The std.xml documentation states This module is considered 
out-dated and not up to Phobos' current standards.


Does this mean that there is some other module I should use for 
xml parsing? Maybe one that is not in the standard distribution 
yet because it is beta?


I'd like to convert a xml-based tool I have written in another 
language to D as an experiment, but I'd like to use libraries 
that are likely to stay up to date.


Bascally it entails:
- reading a xml file
- build a dom for it
- optimize it
- write it back to another xml file

What options do I have in terms of actively maintained libraries 
that are suitable for this kind of utility? Beta quality is ok.


Re: std.xml

2014-01-09 Thread Jacob Carlborg
On 2014-01-10 01:02, Ola Fosheim Grøstad 
ola.fosheim.grostad+dl...@gmail.com wrote:

The std.xml documentation states This module is considered out-dated
and not up to Phobos' current standards.

Does this mean that there is some other module I should use for xml
parsing? Maybe one that is not in the standard distribution yet because
it is beta?

I'd like to convert a xml-based tool I have written in another language
to D as an experiment, but I'd like to use libraries that are likely to
stay up to date.

Bascally it entails:
- reading a xml file
- build a dom for it
- optimize it
- write it back to another xml file

What options do I have in terms of actively maintained libraries that
are suitable for this kind of utility? Beta quality is ok.


As far as I know, std.xml has been considered out of date for years, 
nothing has replaced it yet. I'm using the XML parser from Tango. It has 
a pull parser and an XML document API.


Tango will most likely not get any new features but there are developers 
here keeping it up to date with the latest compiler changes.


http://siegelord.github.io/Tango-D2/
https://github.com/SiegeLord/Tango-D2

--
/Jacob Carlborg


Re: problem parsing xml (std.xml)

2012-05-07 Thread Stanislav Blinov
Just a guess, but wouldn't book be the root node of the 
document, thus not qualifying for the onStartTag?


problem parsing xml (std.xml)

2012-05-06 Thread Minas
I'm trying to use std.xml to parse a small snippet of xml (for 
now).


This is my code:

[code]
void main(string[] args)
{
string xmlText = ?xml version=\1.0\?\n ~
 book ~
  Test ~
 /book;
DocumentParser doc = new DocumentParser(xmlText);

doc.onStartTag[book] = (ElementParser el)
{
writeln(book opening found.);
};

doc.parse();
[/code]

My guess is that it would print book opening found, but nothing 
is printed. I guess I made something wrong(?)


onStartTag for root node in std.xml

2011-12-22 Thread Heromyth
In the test code, the onStartTag will not be called for the root node set.

The onEndTag is OK, and the onStartTag is OK for sub nodes.

Is this a bug, or just it is? Can anybody confirm it?
Thanks.

// test.d
module main;

import std.string;
import std.stdio;
import std.xml;

int main(string[] argv)
{
string s = r?xml version='1.0'?
set
oneA/one
!-- comment --
twoB/two
/set;

string tempStr;

auto xml = new DocumentParser(s);

xml.onStartTag[set] = (ElementParser xml)
{
tempStr = start= ~  xml.tag.name;
writefln(tempStr);
xml.parse();
};

xml.onEndTag[set] = (in Element e)
{
tempStr = end= ~ e.tag.name;
writefln(tempStr);
};

xml.parse();

   return 0;
}


std.xml

2011-11-29 Thread bioinfornatics
Dear
I convert my lib tango/d1 to phobos/d2 so i need use std.xml but i have
heard they are sometime ago std.xml will be updated. I do not want do
twice time the works. So my question is: std.xml will be deprecated or
not ?

thanks



Re: std.xml

2011-11-29 Thread Jonathan M Davis
On Tuesday, November 29, 2011 23:47:33 bioinfornatics wrote:
 Dear
 I convert my lib tango/d1 to phobos/d2 so i need use std.xml but i have
 heard they are sometime ago std.xml will be updated. I do not want do
 twice time the works. So my question is: std.xml will be deprecated or
 not ?

Yes. std.xml is definitely going to be replaced. Unfortunately, the replacement 
isn't done yet and has no ETA that I'm aware of.

- Jonathan M Davis


Re: std.xml

2011-11-29 Thread Jesse Phillips
bioinfornatics Wrote:

 Dear
 I convert my lib tango/d1 to phobos/d2 so i need use std.xml but i have
 heard they are sometime ago std.xml will be updated. I do not want do
 twice time the works. So my question is: std.xml will be deprecated or
 not ?
 
 thanks

I don't think there is an affirmative on what is replacing std.xml, but it is 
going to get replaced and has even been suggested to be removed until that time.

Personally I use xmlp, http://www.dsource.org/projects/xmlp/ which is intended 
to be a candidate for std.

http://www.dsource.org/projects/xmlp/browser/trunk/std


Re: std.xml

2011-11-29 Thread bioinfornatics
Le mardi 29 novembre 2011 à 18:10 -0500, Jonathan M Davis a écrit :
 On Tuesday, November 29, 2011 23:47:33 bioinfornatics wrote:
  Dear
  I convert my lib tango/d1 to phobos/d2 so i need use std.xml but i have
  heard they are sometime ago std.xml will be updated. I do not want do
  twice time the works. So my question is: std.xml will be deprecated or
  not ?
 
 Yes. std.xml is definitely going to be replaced. Unfortunately, the 
 replacement 
 isn't done yet and has no ETA that I'm aware of.
 
 - Jonathan M Davis

no ETA erf, how i do ?

at least can i know if std.xml will be replaced by xmlp ?



Re: std.xml

2011-11-29 Thread Jonathan M Davis
On Wednesday, November 30, 2011 03:42:33 bioinfornatics wrote:
 Le mardi 29 novembre 2011 à 18:10 -0500, Jonathan M Davis a écrit :
  On Tuesday, November 29, 2011 23:47:33 bioinfornatics wrote:
   Dear
   I convert my lib tango/d1 to phobos/d2 so i need use std.xml but i
   have
   heard they are sometime ago std.xml will be updated. I do not want
   do
   twice time the works. So my question is: std.xml will be deprecated
   or
   not ?
  
  Yes. std.xml is definitely going to be replaced. Unfortunately, the
  replacement isn't done yet and has no ETA that I'm aware of.
  
  - Jonathan M Davis
 
 no ETA erf, how i do ?
 
 at least can i know if std.xml will be replaced by xmlp ?

You can't know. The current std.xml _will_ be replaced. It is considered to be 
of unacceptably low quality. xmlp is the likely candidate to replace it, but 
it must be completed and go through Phobos' review process before it can be 
added to Phobos. And even if it does pass that review, it's likely to undergo 
a number of changes in the process. It's not possible to use any xml module at 
this point with the idea that it will be definitively adopted as D's standard 
xml module without breaking your code. The current std.xml is going to be 
removed, but what exactly is going to replace it is not yet known.

- Jonathan M Davis


Re: std.xml

2011-11-29 Thread Jacob Carlborg

On 2011-11-29 23:47, bioinfornatics wrote:

Dear
I convert my lib tango/d1 to phobos/d2 so i need use std.xml but i have
heard they are sometime ago std.xml will be updated. I do not want do
twice time the works. So my question is: std.xml will be deprecated or
not ?

thanks


I've created a wrapper around std.xml which have basically the same API 
as the Tango XML module. If you're lucky you can use my wrapper as a 
drop-in replacement. Actually it may not be complete enough for your 
needs but you could give it a try.


You need these two files:

https://github.com/jacob-carlborg/orange/blob/master/orange/xml/PhobosXml.d

https://github.com/jacob-carlborg/orange/blob/master/orange/xml/XmlDocument.d

PhobosXml is the original std.xml with a few minor modifications. 
XmlDocument is the actual wrapper.


--
/Jacob Carlborg


Re: std.xml empty element

2011-02-26 Thread Jacob Carlborg

On 2011-02-26 07:20, Tom wrote:

El 25/02/2011 20:07, Jacob Carlborg escribió:

On 2011-02-25 21:11, Tom wrote:

El 24/02/2011 19:40, Tom escribió:

El 24/02/2011 09:51, Jacob Carlborg escribió:

On 2011-02-24 06:48, Tom wrote:

Hi, how can I create an empty element with current D2 std.xml Element
implementation?

stdout.writeln(new Element(foo)); // Shields foo/foo instead of
foo /

Thanks in advance,
Tom;


http://d.puremagic.com/issues/show_bug.cgi?id=4394



I see :(
Thanks...


Lucky me, 2.052 solves this bug and doesn't break anything.

Tom;


Really? Which changeset?



Not sure what you mean, but it seems it got fixed when 4069 was resolved...
http://d.puremagic.com/issues/show_bug.cgi?id=4069

Tom;


Ok, thanks. I was referring to the actual code change that fixed the 
problem, which would be: 
https://github.com/D-Programming-Language/phobos/commit/b3ad939cf41adfefd33b16d2d91ca56d568cddac


--
/Jacob Carlborg


Re: std.xml empty element

2011-02-25 Thread Tom

El 24/02/2011 19:40, Tom escribió:

El 24/02/2011 09:51, Jacob Carlborg escribió:

On 2011-02-24 06:48, Tom wrote:

Hi, how can I create an empty element with current D2 std.xml Element
implementation?

stdout.writeln(new Element(foo)); // Shields foo/foo instead of
foo /

Thanks in advance,
Tom;


http://d.puremagic.com/issues/show_bug.cgi?id=4394



I see :(
Thanks...


Lucky me, 2.052 solves this bug and doesn't break anything.

Tom;


Re: std.xml empty element

2011-02-25 Thread Jacob Carlborg

On 2011-02-25 21:11, Tom wrote:

El 24/02/2011 19:40, Tom escribió:

El 24/02/2011 09:51, Jacob Carlborg escribió:

On 2011-02-24 06:48, Tom wrote:

Hi, how can I create an empty element with current D2 std.xml Element
implementation?

stdout.writeln(new Element(foo)); // Shields foo/foo instead of
foo /

Thanks in advance,
Tom;


http://d.puremagic.com/issues/show_bug.cgi?id=4394



I see :(
Thanks...


Lucky me, 2.052 solves this bug and doesn't break anything.

Tom;


Really? Which changeset?

--
/Jacob Carlborg


Re: std.xml empty element

2011-02-25 Thread Tom

El 25/02/2011 20:07, Jacob Carlborg escribió:

On 2011-02-25 21:11, Tom wrote:

El 24/02/2011 19:40, Tom escribió:

El 24/02/2011 09:51, Jacob Carlborg escribió:

On 2011-02-24 06:48, Tom wrote:

Hi, how can I create an empty element with current D2 std.xml Element
implementation?

stdout.writeln(new Element(foo)); // Shields foo/foo instead of
foo /

Thanks in advance,
Tom;


http://d.puremagic.com/issues/show_bug.cgi?id=4394



I see :(
Thanks...


Lucky me, 2.052 solves this bug and doesn't break anything.

Tom;


Really? Which changeset?



Not sure what you mean, but it seems it got fixed when 4069 was resolved...
http://d.puremagic.com/issues/show_bug.cgi?id=4069

Tom;


Re: std.xml empty element

2011-02-24 Thread Jacob Carlborg

On 2011-02-24 06:48, Tom wrote:

Hi, how can I create an empty element with current D2 std.xml Element
implementation?

stdout.writeln(new Element(foo)); // Shields foo/foo instead of
foo /

Thanks in advance,
Tom;


http://d.puremagic.com/issues/show_bug.cgi?id=4394

--
/Jacob Carlborg


Re: std.xml empty element

2011-02-24 Thread Jesse Phillips
Tom Wrote:

 Hi, how can I create an empty element with current D2 std.xml Element 
 implementation?
 
 stdout.writeln(new Element(foo)); // Shields foo/foo instead of 
 foo /
 
 Thanks in advance,
 Tom;

One issue with this is that you can not determine what can be shortened to this 
form without a DDT. It is only valid if it is specified to be legal in the DDT. 
Though I think it might only be the case for v1.0 and not v1.1.



Re: std.xml empty element

2011-02-24 Thread Tom

El 24/02/2011 09:51, Jacob Carlborg escribió:

On 2011-02-24 06:48, Tom wrote:

Hi, how can I create an empty element with current D2 std.xml Element
implementation?

stdout.writeln(new Element(foo)); // Shields foo/foo instead of
foo /

Thanks in advance,
Tom;


http://d.puremagic.com/issues/show_bug.cgi?id=4394



I see :(
Thanks...


std.xml empty element

2011-02-23 Thread Tom
Hi, how can I create an empty element with current D2 std.xml Element 
implementation?


stdout.writeln(new Element(foo)); // Shields foo/foo instead of 
foo /


Thanks in advance,
Tom;


Re: std.xml empty element

2011-02-23 Thread Tom

Oops, I mean, yields :S

El 24/02/2011 02:48, Tom escribió:

Hi, how can I create an empty element with current D2 std.xml Element
implementation?

stdout.writeln(new Element(foo)); // Shields foo/foo instead of
foo /

Thanks in advance,
Tom;