Ex10: HTML Document without h1?

Benutzeravatar
mmi1991
Computerversteher
Computerversteher
Beiträge: 349
Registriert: 20. Okt 2011 18:46
Wohnort: Hattersheim

Ex10: HTML Document without h1?

Beitrag von mmi1991 »

Hi there,
Is it allowed to start a html document without a h1 headline? Because if it is allowed it would maybe create some ugly constructs for the PaginatedDocumentBuilder to get rid of the plain html document at the beginning. We'd like to know whether a non plain html document is allowed.Thanks
Ophasentutor SoSe 2014, WiSe 2015/16
Alle Angaben wie immer ohne Gewähr

imaier
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 21. Okt 2013 21:27

Re: Ex10: HTML Document without h1?

Beitrag von imaier »

No, you can't assume that it starts with an h1. It is really easy to solve this without complicating the code much (a single if then else) if you structure it well.

What is a plain HTML document?

Cheers,
Ingo

burgi
BASIC-Programmierer
BASIC-Programmierer
Beiträge: 115
Registriert: 15. Apr 2009 18:08
Wohnort: Ludwigshafen

Re: Ex10: HTML Document without h1?

Beitrag von burgi »

Hello Ingo,

I think I had the same problem as the guys above. "A plain HTML document" means a HTML document without body content. This can occure if the PaginateDocumentBuilder is used for the first time, because the local variable which is holding the SimpleDocumentBuilder has to be initialized. Thus this empty SimpleDocumentBuilders result will be added to the Seq[String], if an H1 arrives before any other (body) elements arrive.

I personally solved this problem using a boolean flag, indicating the first usage of the PaginatedDocumentBuilder, for sure not the most elegant and performand way, but at the moment I don't really see another way to overcome with this.

Greetings Dominic

imaier
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 21. Okt 2013 21:27

Re: Ex10: HTML Document without h1?

Beitrag von imaier »

Here is a hint: whenever you want to avoid using a boolean flag, try to find some other state from which you can infer the true/false state that you want to express with your boolean value (the size of a collection/isEmpty is a common candidate).

Cheers,
Ingo

burgi
BASIC-Programmierer
BASIC-Programmierer
Beiträge: 115
Registriert: 15. Apr 2009 18:08
Wohnort: Ludwigshafen

Re: Ex10: HTML Document without h1?

Beitrag von burgi »

Thanks for the hint,

but in this special case the isEmpty trick doesn't match, as elements are appended to the string sequence via the result() method of the simpleBuilder and therefor only if a new headline arrives or the html construction is cloased via PaginatedBuilders result method.

Greetings Dominic

Benutzeravatar
mmi1991
Computerversteher
Computerversteher
Beiträge: 349
Registriert: 20. Okt 2011 18:46
Wohnort: Hattersheim

Re: Ex10: HTML Document without h1?

Beitrag von mmi1991 »

burgi hat geschrieben:but in this special case the isEmpty trick doesn't match, as elements are appended to the string sequence via the result() method of the simpleBuilder and therefor only if a new headline arrives or the html construction is cloased via PaginatedBuilders result method.
That's our problem as well. We "solved" it by checking the length of the current html document vs. the length of a new html document. Since a new HTML document (the plain, empty one) will always have a smaller size than a document with content it semes to solve the problem.
Ophasentutor SoSe 2014, WiSe 2015/16
Alle Angaben wie immer ohne Gewähr

imaier
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 21. Okt 2013 21:27

Re: Ex10: HTML Document without h1?

Beitrag von imaier »

You are open to return an empty sequence of documents if nothing gets added to the paginated builder. I am not sure whether this addresses your problem since I can't really follow the reasoning in your last post. I do have a very simple implementation of the paginated builder, with a single line that takes care of an initial h1-less HTML.

Cheers,
Ingo

Antworten

Zurück zu „Archiv“