[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] <xsl:insert> - Further Description - Simpler Example
Tom: and XML DEV Since Tom asked me for simpler examples .... I am resubmitting a simpler example in hopes that this helps.... ===================================================== Begin simpler example...============================= ===================================================== ====here are the source files ========================== ===========begin master.xml============================ <?xml version="1.0" ?> <?xml:stylesheet type="text/xsl" href="wsb_include.xsl" ?> <COMPANY> <HEADER/> <MENU/> <CONTENT/> <FOOTER/> </COMPANY> ===========end master.xml============================ the following file is the master template....which is copied and then the only thing that is changed is the "name" of the content file...since content changes from web page to web page ...while the other 3 files change but since they are to be the same in all copies of the template, there is no since in opening 50 template copies to make changes to the header, menu and footer...rather just have one xsl file for header, menu and footer, include them in the master, then when changes occur to header, menu and footer, the inclusion element causes them to be propagated throughout the copies of the master xsl template.... from another perspective ... this web site you have one header, menu, footer xsl file, but many content xsl files....content1.xsl, content2.xsl etc.. using database terms here...when you change anything anywhere on the site, you only change it one place and one place only... meaning...any change to the header, menu or footer occurs only in the header, menu, footer xsl files and is therefore reflected throughout the site since they are included in all copies of the master template...whereas content is unique to each copy of the master and if content changes then you would just edit the content file for that particular copy of the master xsl template....of course you could insert the content directly into the copy of the master template...but either way still maintains the directive to have style (which is still data) occur in one place and one place only.... since I can not position the xsl:include or xsl:import anywhere except at the top of the master.xsl file, I am able to make the include and import elements part of the master.xsl file but not able to merge them into cell locations of the master table where I want them....that is problem.... Thanks Jim ==========begin master.xsl ================================== <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:space="preserve"> <xsl:include href="header.xsl"> <xsl:include href="menu.xsl"> <xsl:include href="content.xsl"> <xsl:include href="footer.xsl"> <xsl:template match="COMPANY/MASTERXSL"> <!-- script section begins ////////////////////////////////////////// --> <!-- <xsl:script> <![CDATA[ function foo(varFoo1) { return varFoo2 = varFoo1; } ]]> </xsl:script> --> <!-- script section ends //////////////////////////////////////////// --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></meta> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"></meta> <meta name="ProgId" content="FrontPage.Editor.Document"></meta> <title>SomeCompany (c) 2000</title> </head> <body topmargin="0" leftmargin="0"> <table name="MasterTable" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td ><!--begin cell 1 --> </td> <tr> <td><!--begin cell 2 --> </td> </tr> <tr> <td><!--begin cell 3 --> </td> </tr> <tr> <td><!--begin cell 4 --> </td> </tr> </table><!-- end MasterTable --> </body> </html> </xsl:template> </xsl:stylesheet> ==========end master.xsl ================================== ==============begin header.xsl ==================== <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:space="preserve"> <xsl:template match="COMPANY/HEADER"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td ><!--begin header content --> </td> </tr> </table> </xsl:template> </xsl:stylesheet> ==============begin header.xsl ==================== ==============begin menu.xsl ==================== <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:space="preserve"> <xsl:template match="COMPANY/MENU"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td ><!--begin menu content --> </td> </tr> </table> </xsl:template> </xsl:stylesheet> ==============begin menu.xsl ==================== ==============begin content.xsl ==================== <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:space="preserve"> <xsl:template match="COMPANY/CONTENT"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td ><!--begin content content--> </td> </tr> </table> </xsl:template> </xsl:stylesheet> ==============begin content.xsl ==================== ==============begin footer.xsl ==================== <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:space="preserve"> <xsl:template match="COMPANY/FOOTER"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td ><!--begin footer content --> </td> </tr> </table> </xsl:template> </xsl:stylesheet> ==============begin footer.xsl ==================== ================here is what the merged xsl file needs to look like before I send submit it for "FINAL" transformation ==================== <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:space="preserve"> <xsl:include href="header.xsl"> <xsl:include href="menu.xsl"> <xsl:include href="content.xsl"> <xsl:include href="footer.xsl"> <xsl:template match="COMPANY/MASTERXSL"> <!-- script section begins ////////////////////////////////////////// --> <!-- <xsl:script> <![CDATA[ function foo(varFoo1) { return varFoo2 = varFoo1; } ]]> </xsl:script> --> <!-- script section ends //////////////////////////////////////////// --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></meta> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"></meta> <meta name="ProgId" content="FrontPage.Editor.Document"></meta> <title>SomeCompany (c) 2000</title> </head> <body topmargin="0" leftmargin="0"> <table name="MasterTable" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td ><!--begin cell 1 --> ================================================================ ================================================================ =========this is where I need the style from header to appear=== <!-- begin insertion of header style --> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td ><!--begin header content --> </td> </tr> </table> <!-- end insertion of header.xsl --> ================================================================ </td> <tr> <td><!--begin cell 2 --> ================================================================ ================================================================ =========this is where I need the style from menu to appear=== <!-- begin insertion of menu style --> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td ><!--begin menu content --> </td> </tr> </table> <!-- end insertion of menu.xsl --> ================================================================ </td> </tr> <tr> <td><!--begin cell 3 --> ================================================================ =========this is where I need the style from content to appear=== <!-- begin insertion of content style --> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td ><!--begin content content --> </td> </tr> </table> <!-- end insertion of content.xsl --> ================================================================ </td> </tr> <tr> <td><!--begin cell 4 --> ================================================================ =========this is where I need the style from footer to appear=== <!-- begin insertion of footer style --> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td ><!--begin footer content --> </td> </tr> </table> <!-- end footer of header.xsl --> ================================================================ </td> </tr> </table><!-- end MasterTable --> </body> </html> </xsl:template> </xsl:stylesheet> ====================================================== End simpler example....=============================== ====================================================== |-----Original Message----- |From: tpassin@h... [mailto:tpassin@h...] |Sent: Monday, July 24, 2000 9:45 PM |To: Xml-Dev@Xml. Org |Subject: Re: <xsl:insert> - Further Description | | |Jim Garrett has been asking for help with his complex stylesheet situation: |> |> |> What I am doing is attempting to do is use a master xsl (listing 1) |> sheet as a template for all pages on a web site... |> |> This way I can just copy a new instance of the master and |> only have to change the maincontent.xsl sheet that has |> the different content for each page ...the logo, menu, |> footer would not have to be edited in all the copies of |> the templates...rather the logo, menu, footer, would only |> have to be edited just once in their respective xsl files |> in order to propagate throughout all the instances of the |> master template... |> |> |Trouble is, Jim, I can't see what your problem is. It would be better if |you showed a before and after version, since xslt performs |***transformations***. You show places where it looks like xsl:insert |works, then you say it doesn't. What transformation does not work with it? |If you only show the style sheet, everything stays abstract and we have to |guess what you are trying to accomplish - basically do a reverse |engineering |job. Show the untransformed and the transformed files, and highlight the |parts that need to change for different sites. Then show examples of the |kind of changes you need to accomodate. Preferably, don't show everything, |just representative examples that do and don't work. | |Seems to me that this would be a good place to use global parameters - |although how to set them (if you can) is xslt-processor |implementation-dependent. You could pass in all kinds of file names and |settings that way. | |Maybe your page design is too complex. Maybe you should be doing it in |frames. But we can't tell. | |Cheers, | |Tom Passin |
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|