[Part 3] Assets, Atom Feeds, and AspectXML - The Triple Threat of Web Development?

by M. David Peterson

Related link: http://www.aspectxml.org




[UPDATE : [2005.09.30 08:07:00AM MST]

Russ is busy trying to finish three other *MAJOR* projects at the moment, including his Master's Thesis for his MSc in Computer Science from Oxford University. As soon as he is able to break away for a few moments he plans to make his follow-up post to this overview.




In the mean time... At the moment I am working on updating the XSLT Test Suite I wrote a while back to introduce the concept of using reusable pre-defined XML-based 'templates' that can be called by its 'id' attribute and as such 'woven' into the result output of the 'calling' XML. While this post from last January is more focused on using this general idea with an idea that Dimitre Novatchev posted to XSL-List, it should give you a good feel for how things work. I plan to extend things a bit more and prep the code-base to be integrated into AspectXML. When I'm done with that I will make a post explaining how things work. I'm not sure if that will happen today (Sept. 30th, 2005) but at the moment thats the plan.]



[Original Post]

Wow! Its been a combination of both fun and crazy all rolled into one over the last week and a half, the result of which is still being baked, but is getting closer and closer by the minute for the initial release. However what I am refering has nothing to do with the content of this post, that of Assets, Atom Feeds, and AspectXML. Before I get ousted from the good graces of the O'Reilly development community (a membership in which I greatly cherish!) I want to quickly post the updates I made a week or so back to the AspectXML source files.

The plan for this post is to cover the following-topics in short explanation, relying on the idea that if the code is written and documented well it should be able to speak for itself without need for extended explanation.

Still, Aspect-Oriented Programming in general can have a difficult learning curve in and of itself if things are not handled carefully from the beginning. To ensure that this doesn't become a factor I have spoken with Russ Miles, my good friend and partner in several OSS, Open Standard development efforts who also, as many of you know, just so happens to be the original visionary behind AspectXML.

Over the last year and half since the two of put our heads together, developed, and released the first implementation of the AspectXML concept Russ has continued in his role as project motivator/leader promoting the AOP development paradigm in general to pretty much anyone who would listen, even go as far as jumping on a plane and flying over that great pond that divides the US from the UK, to plant his foot in my general corner of the world to help promote these ideas to the development staff at Amazon.com. In fact, that reminds me... I have pics of Russ, Kurt (Cagle), and myself that I completely forgot to post. I need to take care of that pronto! I'll let you know when I do.

Regarding the approach to first understand AspectXML before moving forward with the integration of the Assets stored in Atom feeds

Keeping things on focus, while AOP in general sits at the core of everything that lives in the hacker side of Russ Miles, the AspectXML project is without a doubt his AOP baby. In moving forward I want to ensure that the proper person is placed into the proper mindset within the XML development community when thinking about AOP and AspectXML in general. As such, Russ and I have started to coordinate our efforts in developing the content for the concept I presented for the first time nearly a month ago, this being the third piece in this series entitled "Assets, Atom Feeds, and AspectXML : The Triple Threat of Web Development?" This is a very new, very exciting, and potentially far-reaching technology in the area of XML-based web development which contains the potential to gain extensive amounts of XML developer mind share. But at the same time there is risk in losing that mindshare just as fast if these concepts are presented before the well-known hurdles that exist between an OOP-minded developer and the AOP development paradigm are given proper focus and attention, extending from this new area of understanding once it has been established and then reached.

At present time Russ is working on an extension to this post, but with a more more AOP-centric focus to ensure that this core foundation of Aspect-Oriented Programming is given proper airtime. It is my understanding that he plans to have this ready and posted in the next 24-48 hours. Once he has made this post and feels confident that we can move forward without alienating the entire XML development community in doing so we plan to focus on the extended pieces of this series, that of bringing the ideas of asset management together with your standard, run of the mill hyperlink, blog entry, photograph, etc... and using the Atom publication format to both contain as well as list these resources in a collection of common threads that exists between these items whether that be person, place, or thing that these items represent.

With all of this said, I also don't want to step in the way of progress

Because AspectXML has been around now for well over a year, many of you may have at least some experience with looking at the general idea presented and as such have a decent understanding of how things work. As such, withou taking things beyond the basics, focusing completely on AspectXML from a general technology standpoint I plan to quickly showcase the basic foundation of AspectXML to then leave you with full access to the source files to take a look at if you feel ready to do so, or simply hold off for now if you don't. This will act as a good study source to aid in understanding the basics as well as laying the groundwork for how we are going to use the principals of Aspect-Oriented Programming in combination with your the standard Atom 1.0 data feed to act as a storage and retrieval mechanism in which the content can be woven with other related content and the output "re-written" to something more appropriate to the current platform and technolgy in use.

First, the code file names and a definition of their general purpose:

There are three(3) total files that are a part of the basic weaving AspectXML package. They are as follows:
  • instance.xml : The file we use to represent any given instance in which a weaving process is invoked.
  • aspectDefinition.xml : In essence this is the "language" in which we use to tell the weaving engine what to do when it encounters an element with a specific element or attribute name.
  • aspectXML_basic_weave.xslt : The transformation file in which does all of the weaving magic based on the combination of instance.xml and aspectDefinition.xml.
NOTE: While the actual weaving processing can seem somewhat complicated, if you always keep in mind that the instance file is driving the show, using the names of the elements and attributes as a way of telling the weaving engine what it should look for within the aspectDefinition.xml file to match against, things will be easier to keep in order during the weaving process. Of course once a match has been made control is temporarily handed over to the aspectDefinition.xml in which tells the weaving engine what elements and attributes need be put in place of the current instance being evaluated, and what the values of these elements and attributes should be. But once this process has completed the instance file is given back control to continue in its recursive ways until each and every instance element has been evaluated and processed, resulting in the final output of the overall weaving process.

The AspectXML "Language"

So that we can gain a basic understanding of the general language elements contained withing AspectXML the following is a list of the keywords that we will be using to gain total control of the outputm, no matter what we might want that to be. Each keyword contains a general definition which should be helpful in understanding things as we move through the explanation of the weaving process.

Keywords that apply to elements only:

  • before : element with the specified name and value should be placed before the current instance element in the output.
  • after : element with the specified name and value should be placed after the current instance element in the output.

Keyword that can be applied to both elements and attributes:

  • around : In quite literal terms the around keyword tells the weaving engine to swallow the current element or attribute whole and replace it with the specified element or attribute with the specified value.

Keyword that can only be applied to attributes:

  • flow : the specified attribute name and value should be placed within the flow of the attribute set of the current instance element. Because there is no such thing as attribute "order" (unless of course your speaking in terms of conanical XML, using a specified algorithm as a way of comparing two XML files for differences. But even this is application specific and has nothing to do with XML from a parsing standpoint. As such, theres no such thing as attribute order as far as anything we're concerned with)

The code

Before we get into extending our understanding into why there is no 'before' and 'after' keywords for attributes, and the 'flow' keyword for elements, lets first look at the code from the above mentioned files, run this code through various tests, then look at the result of these tests to see if this alone might bring things into light in a way that can be seen directly through code, rather than a textual explanation in and of itself. Once we reach that point I plan to leave things as is, allowing time for Russ to develop his follow-up piece, to then extend, as mentioned above, into the new areas that this series is intended to present.

[NOTE : I have posted the updated files to http://www.aspectxml.org/files. This directory is browseable.]

Again, the indivdual files to take note of are:

File One: instance.xml

File Two: aspectDefinition.xml

File Three: aspectXML_basic_weave.xslt

For the purpose of showcasing the result of the above keywords "in action" I have created six separate aspect definition files that, when applied to our sample instance file, will enable us to look at a complete base of the results each keyword will have on the element and/or attribute that has been specified as its "processing target". With these results in place it is my hope that you will make the immediate connection to the effect this could possibly have in regards to the overall subject matter of this series, causing a similar "heh! I get it" that is common in the XSLT world when things finally come together and 'click', which is a word often used to describe the moment of sudden and overhwhelming realization at just how simple 'simple' truly is. When this happens (and I'm pretty sure that for most of you reading this it will happen almost immediattely) my hope it that you will then recognize the same potential that both Russ, myself as well as several other members of our collective development project communities have seen and as such are extremely excited about the possibilities and potential that this subject matter brings forth.

For now I will simply list the:

  1. original XML instance file
  2. the element and attribute names and values for each of the 6 test cases
  3. the resulting woven instance file directly following each test case. 

 

This format should allow for a clean, simple, and direct comparison of each of these three states, showcasing quite visibly the difference between the instance and the result.   With the test case values sitting between the original and and the output  it should allows for a clean reference point to compare what the keyword and associated value(s) used to instantiate the various pieces of each instruction at each recursive pass through the associated portion fo the aspectDefintion file which, again, is representative of the keyword and associated values contained in the linked aspectDefinition-*.xml file for each portion of the test:

In quick reference the test values are as follows: 

Test 1: <elementAdvice name="current" type="before"/>

<attributeAdvice name="current" type="flow"/>



Test 2: <elementAdvice name="current" type="before"/>

<attributeAdvice name="current" type="around"/>



Test 3: <elementAdvice name="current" type="around"/>

<attributeAdvice name="current" type="flow"/>



Test 4: <elementAdvice name="current" type="around"/>

<attributeAdvice name="current" type="around"/>



Test 5: <elementAdvice name="current" type="after"/>

<attributeAdvice name="current" type="flow"/>



Test 6: <elementAdvice name="current" type="after"/>

<attributeAdvice name="current" type="around"/>

 




The aspectDefinition.xml file format that the above elements and attributes apply to is as follows:

This particular file the from test five showcased below, but the general structure and layout is exactly the same for all associated aspectDefintion.xml files



<?xml version="1.0" encoding="UTF-8"?>
<!-- filename: aspectDefinition-5.xml -->
<aspects>
<aspect name="HelloWorld">
<pointcut name="namedElementPointcut">
<unaryPointcutExpr operator="" pattern="Message"/>
</pointcut>
<pointcut name="namedAttributePointcut">
<unaryPointcutExpr operator="" pattern="Message/@format"/>
</pointcut>
<pointcut name="namedAttributePointcut">
<unaryPointcutExpr operator="" pattern="Message/@type"/>
</pointcut>
<adviceDefinition>
<elementAdvice name="current" type="after">
<pointcut>
<namedPointcutExpr reference="namedElementPointcut"/>
</pointcut>
<adviceContents>
<WovenTag> Hello World </WovenTag>
</adviceContents>
</elementAdvice>
</adviceDefinition>
<adviceDefinition>
<attributeAdvice name="current" type="flow">
<pointcut>
<namedPointcutExpr reference="namedAttributePointcut"/>
</pointcut>
<attribute type="xs:string">
<name>wovenAttribute</name>
<value>Some Woven Value</value>
</attribute>
</attributeAdvice>
</adviceDefinition>
</aspect>
</aspects>




The test results, layed out as explain above are as follows:

 

Test 1




instance.xml


   	 	 	 	 	 
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<Greeting>
<Message format="text" type="urgent">AspectXML is getting there!</Message>
<Message format="text" type="critical">Getting Closer!</Message>
</Greeting>
</root>


Test 1 keywords/values:

<elementAdvice name="current" type="before"/>

<attributeAdvice name="current" type="flow"/>



result-file: wovenInstance-1.xml


   	 	 	 	 	 	
<?xml version="1.0" encoding="UTF-8"?>
<Greeting>
<WovenTag> Hello World </WovenTag>
<Message format="text" type="urgent" wovenAttribute="Some Woven Value"/>
<WovenTag> Hello World </WovenTag>
<Message wovenAttribute="Some Woven Value" format="text" type="critical"/>
</Greeting>





instance.xml


 

<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<Greeting>
<Message format="text" type="urgent">AspectXML is getting there!</Message>
<Message format="text" type="critical">Getting Closer!</Message>
</Greeting>
</root>



Test 2 keywords/values:


<elementAdvice name="current" type="before"/>

<attributeAdvice name="current" type="around"/>



result-file: wovenInstance-2.xml




<?xml version="1.0" encoding="UTF-8"?>
<Greeting>
<WovenTag> Hello World </WovenTag>
<Message wovenAttribute="Some Woven Value"/>
<WovenTag> Hello World </WovenTag>
<Message wovenAttribute="Some Woven Value"/>
</Greeting>





instance.xml


   	 	 	 	 	 
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<Greeting>
<Message format="text" type="urgent">AspectXML is getting there!</Message>
<Message format="text" type="critical">Getting Closer!</Message>
</Greeting>
</root>


Test 3 keywords/values:


<elementAdvice name="current" type="around"/>

<attributeAdvice name="current" type="flow"/>



result-file: wovenInstance-3.xml


   	 	 	 	 	 

<?xml version="1.0" encoding="UTF-8"?>
<Greeting>
<WovenTag format="text" type="urgent" wovenAttribute="Some Woven Value"> Hello World </WovenTag>
<WovenTag wovenAttribute="Some Woven Value" format="text" type="critical"> Hello World </WovenTag>
</Greeting>





instance.xml


   	 	 	 	 	 
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<Greeting>
<Message format="text" type="urgent">AspectXML is getting there!</Message>
<Message format="text" type="critical">Getting Closer!</Message>
</Greeting>
</root>


Test 4 keywords/values:


<elementAdvice name="current" type="around"/>

<attributeAdvice name="current" type="around"/>



result-file: wovenInstance-4.xml


   	 	 	 	 	 	
<?xml version="1.0" encoding="UTF-8"?>
<Greeting>
<WovenTag wovenAttribute="Some Woven Value"> Hello World </WovenTag>
<WovenTag wovenAttribute="Some Woven Value"> Hello World </WovenTag>
</Greeting>





instance.xml


   	 	 	 	 	 
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<Greeting>
<Message format="text" type="urgent">AspectXML is getting there!</Message>
<Message format="text" type="critical">Getting Closer!</Message>
</Greeting>
</root>


Test 5 keywords/values:


<elementAdvice name="current" type="after"/>

<attributeAdvice name="current" type="flow"/>



result-file: wovenInstance-5.xml


   	 	 	 	 	 	
<Greeting>
<Message format="text" type="urgent" wovenAttribute="Some Woven Value"/>
<WovenTag> Hello World </WovenTag>
<Message wovenAttribute="Some Woven Value" format="text" type="critical"/>
<WovenTag> Hello World </WovenTag>
</Greeting>





instance.xml


   	 	 	 	 	 
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<Greeting>
<Message format="text" type="urgent">AspectXML is getting there!</Message>
<Message format="text" type="critical">Getting Closer!</Message>
</Greeting>
</root>


Test 6 keywords/values:


<elementAdvice name="current" type="after"/>

<attributeAdvice name="current" type="around"/>



result-file: wovenInstance-6.xml


   	 	 	 	 	 

<?xml version="1.0" encoding="UTF-8"?>
<Greeting>
<Message wovenAttribute="Some Woven Value"/>
<WovenTag> Hello World </WovenTag>
<Message wovenAttribute="Some Woven Value"/>
<WovenTag> Hello World </WovenTag>
</Greeting>






And there we have it...

As mentioned, either sometime today or tomorrow Russ Miles will be following things up such that he can bring into this conversation the true background and expertise of a -- well, AOP expert. I then plan to coordinate with him what should take place next based on the response that he receives and the impression he is left with after analyzing the thoughts and questions brought forth by the community at large. While I encourage you to leave any comments or questions at the end of this post, unless they are specific to the XSLT weaving process specifically I plan to leave these questions for Russ, someone who has gobs and gobs of experience, training, and understanding in all that is Aspect-Oriented Programming and how to present the AOP programming methodologies in a way that doesn't sent the XML community "running for the OOP Borders" in which all of us, myself inclusive, tend to have fairly strong backrounds in.

So until next time (which I hope will be sometime soon , all based on the evaluation I receive from Russ in regards to where we should take things next), Russ, I'll pass things on on over to you :)

Enjoy your XML-based Development Day Everyone! :)

So where do we go from here? Do things make complete sense and you are ready to start weaving some magic out of Atom feeds? Or should we slow things down a bit and focuse more on the concepts of AOP, how they related to AspectXML, the then further extend the discussion of AspectXML just what is capable and why?


2 Comments

russellmiles
2005-09-21 08:19:11
Nice work Mark!
A great practical trek through what AspectXML can do for you in it's "basic weave" mode (advanced weave is where it can actually make changes to any associated schema as well as instance files so that woven source can be validated as well).
Great to see a practical example in the limelight for once instead of all my incessant theoretical musings, although there will soon be a linked entry on my own blog with some more of those musings just to keep the ball rolling.
xmlhacker
2005-09-21 08:36:14
Nice work Mark!
Excellent! As mentioned in email I think this will act well in ensuring that both sides of the "UnderstandingAOP equation" are met from both theory and practice. Its tough to practice something you have a hard time even understanding so putting focus into this area I think is really, REALLY important to the overall progress is this project.