Duvida com xsl

olá Pessoal to com uma duvida em xsl, bem tenho os dois arquivos em anexo.

o .xml que sao os views e o .xsl que é a estrutura.

Eu preciso na verdade unificar o arquivo full.xml com tags.xml. observe que temos dados duplicados incosistentes, entao quero deixar tudo isso em um arquivo. O usuario tera um menu para escolher versao resumida (tags.xml)ou full. porem como possa fazer isso sem ter arquivos duplicados?

quem puder ajudar agradeco

Você está perguntando sobre XSL ou XSD ? O XSL faz uma transformação de um XML para outro; o XSD é usado para fazer validação de estrutura de XML.

to perguntando sobre os arquivos xsl, em anexo onde tenho a estrutura para exibir os dados no xml.

como poderia unificar o cvstags.xsl com o cvstags-full.xsl e depender do que o cliente escolher no menu ele ia carregar o full ou o tags.xsl.

Tu podes juntar os dois XSL em um só, passando um parâmetro para diferenciar qual versão ele deve usar. Algo como:

if parametro = tal then versao full else versao light

Em uma empresa onde trabalhei utilizávamos dessa maneira para diferenciar. Geralmente eram relatórios onde o usuário escolhia quais informações deveriam ser mostradas. É um pouco trabalhoso e de difícil manutenção, mas funciona. :slight_smile:

[quote=schistossoma]Tu podes juntar os dois XSL em um só, passando um parâmetro para diferenciar qual versão ele deve usar. Algo como:

if parametro = tal then versao full else versao light

Em uma empresa onde trabalhei utilizávamos dessa maneira para diferenciar. Geralmente eram relatórios onde o usuário escolhia quais informações deveriam ser mostradas. É um pouco trabalhoso e de difícil manutenção, mas funciona. :)[/quote]

rpz poe trabalhoso nisso e dificul manutencao nem se fala. no meu caso eu terei que carregar uma delas, tipo vou carregar a tabela resumida, ai tera um menu logo acima com os link para as outras opcoes tipo relatorio full, porem esse link nao pode levar para um arquivo que tenha codigo duplicado, e sim o arquivo principal que nele eu tenho o full e o resumo. aqui o codigo.

<xsl:choose>
 <xsl:when test="'common'=cvstags/@proper"> <!-- comparamos se o valor está igual a '' (vazio) -->
  <table border="1" cellpadding="0" cellspacing="0">
      <xsl:for-each select="/cvstags/project">
        <xsl:sort select="@id" order="ascending"/>
        <xsl:variable name="project" select="@id"/>
        <tr style="font-size: 200%">
          <td style="background-color: orange" colspan="6">
            <a id="{$project}"/>
	    &#160;<xsl:value-of select="$project"/> - <a href="{concat($audits,$project)}">audits</a> - <a href="http://w3afs.btv.ibm.com/~bwf/projmgmt/cvstags/merge_head.xml">merges</a>
          </td>
        </tr>
        <xsl:if test="branch|tag">
          <tr style="background-color: yellow">
            <th>Date</th>
            <th>From</th>
	    <th>Branch/Tag</th>
	    <th>Description</th>	    
		<th>Status</th>
	    <th>CAT</th>
          </tr>
        </xsl:if>
        <xsl:if test="not(branch|tag)"> <!-- Se nao tem tag ou branch -->
          <tr>
            <td colspan="6" style="background-color: yellow">
              <span style="font-size: 100%">
                WARNING: No Tags or Branches have been configured for <strong><xsl:value-of select="@id"/></strong>!
              </span>
            </td>
          </tr>
        </xsl:if>
        <xsl:for-each select="branch|tag"> <!-- para cada linha, se for tag ou branch, fazer um filtro aqui usando um hide -->
  	 <xsl:sort select="@date" order="descending"/>
	 <xsl:if test="'Test'=@flag or 'Prod'=@flag or 'Dev'=@flag or 'oldTest'=@flag"> <!-- teste pra imprimir so os testes -->
          <tr class="hover">	    
            <xsl:if test="'Prod'=@flag">
              <xsl:attribute name="style">
                background-color: pink;
              </xsl:attribute>
            </xsl:if>
            <xsl:if test="'Dev'=@flag">
              <xsl:attribute name="style">
                background-color: lightgreen;
              </xsl:attribute>
            </xsl:if>
            <xsl:if test="'Test'=@flag">
              <xsl:attribute name="style">
                background-color: lightblue;
              </xsl:attribute>
      	    </xsl:if>
	    <td nowrap="nowrap">
              &#160;
              <span title="Get a patch: $ cvs rdiff -u -D &quot;{@date}&quot; -r &quot;{@name}&quot; newbuild">
                <xsl:value-of select="@date"/>
              </span>
              &#160;
            </td>
            <td>
              &#160;
              <a title="Get a patch: $ cvs rdiff -u -r &quot;{@from}&quot; -r &quot;{@name}&quot; newbuild" target="_new" id="{@from}" href="{concat($cvsweb,$project,'/?only_with_tag=',@from)}">
                <xsl:value-of select="@from"/>
              </a>
              &#160;
            </td>
            <td colspan="1">
              &#160;
		  <a title="Get a patch: $ cvs rdiff -u -r &quot;{@from}&quot; -r &quot;{@name}&quot; newbuild" target="_new" id="{@name}" href="{concat($cvsweb,$project,'/?only_with_tag=',@name)}">
                    <xsl:value-of select="@name"/>
              </a>
              &#160;
            </td>
            <td>
              &#160;
              <span title="Get a patch: $ cvs rdiff -u -D &quot;{@description}&quot; -r &quot;{@name}&quot; newbuild">
                <xsl:value-of select="@description"/>
              </span>
              &#160;
            </td>
            <xsl:variable name="mystatus">
              <xsl:choose>
                <!-- if this tag/branch has status, use it -->
                <xsl:when test="@status">
                  <xsl:value-of select="@status"/>
                </xsl:when>
                <!-- otherwise, use the 'from' tag/branch status -->
                <xsl:otherwise>
                  <xsl:variable name="myfrom" select="@from"/>
                  <xsl:value-of select="parent::project/*[@name=$myfrom]/@status"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <td class="{$mystatus}">
              <xsl:value-of select="$mystatus"/>
            </td>
	   <td>
              &#160;
              <span title="Yes represent that the TAG was installed on CAT some time, not necessary mean that it is installed NOW, maybe there is a more recent CAT instaled">
                <xsl:value-of select="@cat"/>
              </span>
              &#160;
           </td>
	   </tr>
	   </xsl:if> <!-- fim do meu teste -->
        </xsl:for-each><!-- fim - para cada linha, se for tag ou branch, fazer um filtro aqui usando um hide -->
      </xsl:for-each>
    </table>
 </xsl:when>

</xsl:choose>  

quando o proper de .xml recebe common ele carrega a estrutura acima que eh o relatorio resumido, quando eh vazio ele recebe a estrutura completa que eh o codigo abaixo:

<table border="1" cellpadding="0" cellspacing="0">
      <xsl:for-each select="/cvstags/project">
        <xsl:sort select="@id" order="ascending"/>
        <xsl:variable name="project" select="@id"/>
        <tr style="font-size: 200%">
          <td style="background-color: orange" colspan="6">
            <a id="{$project}"/>
            &#160;<xsl:value-of select="$project"/>
          </td>
        </tr>
        <xsl:if test="branch|tag">
          <tr style="background-color: yellow">
            <th>Date</th>
            <th>From</th>
	    <th>Branch</th>
            <th>Tag</th>
	    <th>Description</th>
	    <th>CAT</th>
          </tr>
        </xsl:if>
        <xsl:if test="not(branch|tag)"> <!-- Se nao tem tag ou branch -->
          <tr>
            <td colspan="5" style="background-color: yellow">
              <span style="font-size: 100%">
                WARNING: No Tags or Branches have been configured for <strong><xsl:value-of select="@id"/></strong>!
              </span>
            </td>
          </tr>
        </xsl:if>
        <xsl:for-each select="branch|tag"> <!-- para cada linha, se for tag ou branch, fazer um filtro aqui usando um hide -->
          <xsl:sort select="@date" order="descending"/>
          <tr class="hover">	    
            <xsl:if test="'Prod'=@flag">
              <xsl:attribute name="style">
                background-color: pink;
              </xsl:attribute>
            </xsl:if>
            <xsl:if test="'Dev'=@flag">
              <xsl:attribute name="style">
                background-color: lightgreen;
              </xsl:attribute>
            </xsl:if>
            <xsl:if test="'Test'=@flag">
              <xsl:attribute name="style">
                background-color: lightblue;
              </xsl:attribute>
            </xsl:if>
	          <td nowrap="nowrap">
              &#160;
              <span title="Get a patch: $ cvs rdiff -u -D &quot;{@date}&quot; -r &quot;{@name}&quot; newbuild">
                <xsl:value-of select="@date"/>
              </span>
              &#160;
            </td>
            <td>
              &#160;
              <a title="Get a patch: $ cvs rdiff -u -r &quot;{@from}&quot; -r &quot;{@name}&quot; newbuild" target="_new" id="{@from}" href="{concat($cvsweb,$project,'/?only_with_tag=',@from)}">
                <xsl:value-of select="@from"/>
              </a>
              &#160;
            </td>
            <td colspan="1">            
	     <xsl:choose>
                <xsl:when test="name(.) = 'branch'">
                  &#160; 
                  <a title="Get a patch: $ cvs rdiff -u -r &quot;{@from}&quot; -r &quot;{@name}&quot; newbuild" target="_new" id="{@name}" href="{concat($cvsweb,$project,'/?only_with_tag=',@name)}">
                    <xsl:value-of select="@name"/>
                  </a>
                  &#160;
                </xsl:when>
                <xsl:otherwise>
                  &#160;
                </xsl:otherwise>
              </xsl:choose>
            </td>
            <td>
              <xsl:choose>
                <xsl:when test="name(.) = 'tag'">
                  &#160;
                  <a title="Get a patch: $ cvs rdiff -u -r &quot;{@from}&quot; -r &quot;{@name}&quot; newbuild" target="_new" id="{@name}" href="{concat($cvsweb,$project,'/?only_with_tag=',@name)}">
                    <xsl:value-of select="@name"/>
                  </a>
                  &#160;
                </xsl:when>
                <xsl:otherwise>
                  &#160;
                </xsl:otherwise>
              </xsl:choose>
            </td>
            <td>
              &#160;
              <span title="Get a patch: $ cvs rdiff -u -D &quot;{@description}&quot; -r &quot;{@name}&quot; newbuild">
                <xsl:value-of select="@description"/>
              </span>
              &#160;
            </td>
            <td>
              &#160;
              <span title="Get a patch: $ cvs rdiff -u -D &quot;{@cat}&quot; -r &quot;{@name}&quot; newbuild">
                <xsl:value-of select="@cat"/>
              </span>
              &#160;
            </td>
	 </tr>
        </xsl:for-each><!-- fim - para cada linha, se for tag ou branch, fazer um filtro aqui usando um hide -->
      </xsl:for-each>
    </table>
  </xsl:template>

aqui a estrutura do .xml que define quem carregar:

<cvstags update_time="03-17-2009" updated_by="Camilo Neto" proper="common">

essa ai que diz quem vai carregar. Bem unificar eu ate conseguir peguei o arquivo tags.xml e to importando os xsl:

<?xml-stylesheet href="xsl/cvstags.xsl" type="text/xsl"?>
<?xml-stylesheet href="xsl/cvstags-fulltest.xsl" type="text/xsl"?>

pq neles estao a estrutura entao agora so preciso atualizar tags e mais nada, agora oque preciso eh saber exibir isso, quando o cliente clicar em completo relatorio, resumido.

alguma ideia?