Chapter 11: Adding the Section Tag, Part I


It s time to add a new feature to the XML Notepad. This time it s a multiline section tag. Since Chet has found honest work, I ll have to do a lot of this alone. I ll get in trouble ”and sb it s Chet s fault! [1]

Looking at the Next Few Stories

The XML Notepad is actually fairly useful as it stands. The biggest hassle in producing one of these articles (which were later updated and turned into these chapters) is needing to type something special to get a new set of P tags created, and the notepad solves that problem. But there are a number of candidate things to do next. Here s a list of stories that seem potentially interesting:

  • Add sect1 tag. Each section of text that shows up in the TOC appears inside sect1 tags. Inside the sect1 is a title tag where you put the title. The ability to create a new section would be nice. Then inside the section we go back to typing paragraphs like always. The sect1 tag should be inserted after one we re currently in.

  • When the user types Tab, move the cursor somewhere reasonable. This probably means to the end of the next opening tag, or the beginning of the next closing tag, whichever is closer. This sounds weird, but what it ll do is position the cursor at the beginning of the next paragraph, then at its end, and so on and so on. It should be a quick way to click through the document. We ll want Shift+Tab to go backwards , I suppose.

  • Save a file. Open a file.

  • Prime a new file with a starting document, with headers and such. This will help create the boilerplate needed to support an article.

Of these, the sect1 story seems most useful and will probably involve the most learning in doing it. One of the issues is that the sect1 involves nesting ” that is, it looks like this:

 <sect1><title></title> 
</sect1>

There s the title inside there, and of course there will be paragraphs as well. It might turn out to be a bit tricky getting it to work right and look right. I ll start, however, by assuming it s going to work. No need to borrow trouble from the future.

Also, I had a really neat technical idea. If the TextModel used a simple tree structure, where each node knew its tag and had contents that were a collection of other nodes (or raw text), then rendering the text into the TextPane, even in a nice indented form, would be really easy. I don t have a story that requires me to build that model, but I m interested in it and excited to try it.

Now this could be a good idea, but I also know I m on a slippery programmer slope, putting in some cool technical gadget that the program doesn t really need. I m not going to put it in now, but I may well do a spike on it later. I d advise you to do the same: leave the cool techie stuff for when it s really needed. My experience is that things go better and faster if I stick to simple design with refactoring.

[1] Chet has assumed responsibility for all problems everywhere. If there is a problem in your project or your life, it s Chet s fault. Now stop assigning blame and get on with solving the problem!




Extreme Programming Adventures in C#
Javaв„ў EE 5 Tutorial, The (3rd Edition)
ISBN: 735619492
EAN: 2147483647
Year: 2006
Pages: 291

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net