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
Ex10: HTML Document without h1?
Ex10: HTML Document without h1?
Ophasentutor SoSe 2014, WiSe 2015/16
Alle Angaben wie immer ohne Gewähr
Alle Angaben wie immer ohne Gewähr
Re: Ex10: HTML Document without h1?
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
What is a plain HTML document?
Cheers,
Ingo
Re: Ex10: HTML Document without h1?
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
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
Re: Ex10: HTML Document without h1?
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
Cheers,
Ingo
Re: Ex10: HTML Document without h1?
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
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
Re: Ex10: HTML Document without h1?
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.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.
Ophasentutor SoSe 2014, WiSe 2015/16
Alle Angaben wie immer ohne Gewähr
Alle Angaben wie immer ohne Gewähr
Re: Ex10: HTML Document without h1?
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
Cheers,
Ingo