Upgrading NSTextView to WYSIWYG xml: Where to start looking?

A full layout of how to do this would be great--but I am learning to read code still, so what I'd like instead is to know where I should be looking to understand how to do this.


Here's what I think I know so far: I will need some dictionary which associates a given set of XML tags to a given formatting of text. I know what tags I need to be using, and I know how to do the things I need to do to text in NSTextView, but not how to make <thistag> do that thing, or populate in the xml file by, for instance, setting a bit of text to <h1> (which is just an example).


I believe that I'm going to end up subclassing NSTextView in order to incorporate additional functionality (like track changes) and I know that I'll need a series of available booleans to turn some features on and off. I believe I understand how to associate certain actions like highlighting text with things like getting the value of a highlighted string, changing what happens when you delete or overwrite, etc... NSAttributedString is what I think I'm going to be digging into for that sort of thing.


What I cannot find at all is where to look regarding essentially the ability to load an xml based text file (think Docx) (edit: I'm aware a docx file is a zip file that will need to be opened, parsed, etc) identify all the tags in it (what the dictionary is for) display the text as formatted based on the xml (not far off from how rtf works to begin with) and update the actual xml itself when modifications are made to the text in NSTextView.


If I need to add additional formatting functionality, for instance, do I need to subclass whatever handles the formatting of rich text in the NSTextView and add the additional functionality to that? As in, defining xml tags and such, and how they should be read or applied. I know there is an xml parser, but as far as I know it only parses xml--it doesn't then do anything with that information other than what you tell it to do.


Which classes do I need to be exploring, basically, in order to begin understanding the relationship between NSTextView and whatever determines how text is displayed there, and begin modifying how that happens and what it can do? (I know subclassing NSTextView is pointed out frequently as being something you "shouldn't need to do" but for what I need to accomplish it appears to be the case, and if this was easy someone woulda done it already.)


This project is way out of my depth, but that's just how I roll when it comes to learning things.

Replies

Any luck?