0 Replies Latest reply on Jun 23, 2011 3:28 AM by Ton Blokhuizen

    conditional build tag inside XML/XSL and Baggage files

    Ton Blokhuizen

      Hello,

       

      I have got two problems:

       

      1) How can I apply conditional build tags to a baggage file, so that depending on de tag sometime the file is published, and sometimes not.

      2) How can I apply conditional build tags INSIDE a XSL file, in the same way you can apply Conditional build tags in a topic :

       

      <?rh-cbt_start condition="name of the buildtag" ?> here the value <?rh-cbt_end ?>
      

       

      The project I'm working on is using a navigation tree wich uses XML as input.

      I've also created an XSL file where as much as 10 XML files can me merged to one, see code below:

       

      As you can see, in this example i use 3 variables containing the names of the XML files to be merged.

      So far so good.

       

      Now I want to publish File2.xml and File4.xml (stored in my roboproject as baggage file)

      But, if one of the files is missing on the server the XSL does not work anymore.

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
           <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes" />
           
              <xsl:variable name="with2" select="'File2.xml'" />
           <xsl:variable name="with3" select="'File3.xml'" />
           <xsl:variable name="with4" select="'File4.xml'" />
      
      <xsl:template match="/columns">
              <xsl:for-each select="cell">
                   <xsl:copy-of select="." /> 
              </xsl:for-each>
                 <xsl:for-each select="document($with2)/columns/*">
                      <xsl:copy-of select="." />
                 </xsl:for-each>
             <xsl:for-each select="document($with3)/columns/*">
                      <xsl:copy-of select="." />
                 </xsl:for-each>
                  <xsl:for-each select="document($with4)/columns/*">
                      <xsl:copy-of select="." />
                 </xsl:for-each>     
      </xsl:template>
      </xsl:stylesheet>
      

       

      I would really want to add conditional build tags inside the file so it would look something like this:

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
           <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes" />
           
      
              <?rh-cbt_start condition="tag1"?><xsl:variable name="with2" select="'File2.xml'" /><?rh-cbt_end ?>
           <?rh-cbt_start condition="tag2"?><xsl:variable name="with3" select="'File3.xml'" /><?rh-cbt_end ?>
           <?rh-cbt_start condition="tag3"?><xsl:variable name="with4" select="'File4.xml'" /><?rh-cbt_end ?>
       
      
      
      

       

      Help is appreciated.

       

      Thanx

       

      Ton.