[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Project Organization

Subject: Re: Project Organization
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Tue, 20 Sep 2005 07:44:45 -0400
project organization
Hi Alan,

>
> What more can I do to organize XSLT? Project organization has been a
> real challenge.

One thing you might want to do is have a default or fallback project. So if you have multiple projects, and these projects tend to use the same XSL, you have a location where these defaults can be resolved. If a project needs something different then the particular project can override the default. You can implement a custom javax.xml.transform.URIResolver - something like:

public Source resolve(String href, String base) throws TransformerException {

File file = new File(getWorkDir(), href);

if (file.exists()) {

return new StreamSource(file);

} else {

		file = new File(getFallbackDir(), href);
		
		if (file.exists()) {

			return new StreamSource(file);
			
		} else {
			throw new TransformerException("Could not find file: " + file);
		}
	}
}





Alan wrote:
Here's the details on a method of project organization I've adopted.

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:noun="tag:agtrz.com,2005-09:transform/nouns"
    >
  <xsl:import href="people.xslt"/>
  <xsl:import href="places.xslt"/>
  <xsl:template match="/">
    <xsl:apply-templates select="node()" mode="noun:transform"
  </xsl:template>
</xsl:stylesheet>


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ppl="tag:agtrz.com,2005-09:transform/nouns/people"> xmlns:rt="tag:agtrz.com,2005-09:transform/nouns">

  <!--| Replace with transforms that create something. |-->
  <xsl:template match="node()" mode="ppl:transform"/>

  <xsl:template match="noun[@type = 'person']" mode="noun:transform">
    <xsl:apply-templates select="." mode="ppl:transform"/>
  </xsl:template>

</xsl:styleheet>

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:plc="tag:agtrz.com,2005-09:transform/nouns/places">
    xmlns:rt="tag:agtrz.com,2005-09:transform/nouns">

  <!--| Replace with transforms that create something. |-->
  <xsl:template match="node()" mode="plc:transform"/>

  <xsl:template match="noun[@type = 'place']" mode="noun:transform">
    <xsl:apply-templates select="." mode="plc:transform"/>
  </xsl:template>

</xsl:styleheet>

There seem to be benefits to this sort of modularity, even though it
looks simple enough to be pointless. Putting the logic in separate
mode namespaces helps. It seems to make matters cleaner that
namespaces are "localized". I'm finding myself creating ever smaller
XSLT files, some of which might include only a single template.

Ultimately, I can imagine how the root transform could be generated
via XSLT including the necessary templates.

What more can I do to organize XSLT? Project organization has been a
real challenge.

Thanks.

--
Alan Gutierrez - alan@xxxxxxxxx
    - http://engrm.com/blogometer/index.html
    - http://engrm.com/blogometer/rss.2.0.xml

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.