Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Pattern problem

From: "tshad" <tshad@----------.--->
To: NULL
Date: 8/11/2008 6:28:00 PM

I can't seem to get this pattern to work:

I have stripped down my files for testing:

In a nutshell, what I am trying to do is this:

     <xsl:when test="ancestor::form/@name = '1007'">
      <xsl:value-of select="name[ancestor::form/primary='true']"/>
     </xsl:when>

If the form/@name = '1007', I want to go look at the other form tags to find 
the one that has an attribute primary='true' and use that name for my form 
name.  But I am getting a blank entry.  I was just guessing on this 
statement and not sure how to get it to work:

My xslt file:
*****************************************************
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <xsl:output method="xml" indent="yes"/>
 <xsl:template match="/*">
  <xsl:copy>
   <xsl:apply-templates select="appraisal/data/form/tag | 
appraisal/data/form/section/tag">
    <xsl:sort select="ancestor::form/@primary" order="descending"/>
    <xsl:sort select="ancestor::section/@number" order="ascending" 
data-type="number"/>
   </xsl:apply-templates>
  </xsl:copy>
 </xsl:template>
 <xsl:template match="tag">
  <form>
   <sectionNumber>
    <xsl:value-of select="ancestor::section/@number"/>
   </sectionNumber>
   <primary>
    <xsl:value-of select="ancestor::form/@primary"/>
   </primary>
   <formName>
    <xsl:choose>
     <xsl:when test="ancestor::form/@name = '1007'">
      <xsl:value-of select="name[ancestor::form/primary='true']"/> 
<---------
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="ancestor::form/@name"/>
     </xsl:otherwise>
    </xsl:choose>
   </formName>
   <tagName>
    <xsl:value-of select="@name"/>
   </tagName>
   <flags>
    <xsl:if test="not(@flags)">
     <xsl:attribute name="xsi:nil">true</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@flags"/>
   </flags>
   <format>
    <xsl:if test="not(@format)">
     <xsl:attribute name="xsi:nil">true</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@format"/>
   </format>
   <value>
    <xsl:value-of select="text()"/>
   </value>
  </form>
  <xsl:apply-templates select="addendum[heading | body]"/>
 </xsl:template>
</xsl:stylesheet>
******************************************************

My xml file:
******************************************************
<?xml version="1.0" encoding="utf-8"?>
<Report>
  <appraisal>
    <data>
      <form name="1007" primary="false">
        <section type="subject" number="0">
          <tag name="GR_AGE.1" flags="1" format="4096">4 Yrs.</tag>
        </section>
      </form>
      <form name="reffee" primary="false">
          <tag name="FFHD_NFIP_COMMUNITY_NUMBER.1" flags="0" 
format="0">040040</tag>
      </form>
      <form name="1004_05" primary="true">
        <section type="subject" number="0">
          <tag name="PROP_PHYS_DEFICIENCIES_DESC.1" flags="4" 
format="4096">None apparent </tag>
        </section>
      </form>
    </data>
  </appraisal>
</Report>
********************************************************

My result:
******************************************************
<?xml version="1.0" encoding="utf-8"?>
<Report>
  <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <sectionNumber>0</sectionNumber>
    <primary>true</primary>
    <formName>1004_05</formName>
    <tagName>PROP_PHYS_DEFICIENCIES_DESC.1</tagName>
    <flags>4</flags>
    <format>4096</format>
    <value>None apparent </value>
  </form>
  <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <sectionNumber></sectionNumber>
    <primary>false</primary>
    <formName>reffee</formName>
    <tagName>FFHD_NFIP_COMMUNITY_NUMBER.1</tagName>
    <flags>0</flags>
    <format>0</format>
    <value>040040</value>
  </form>
  <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <sectionNumber>0</sectionNumber>
    <primary>false</primary>
    <formName></formName>                      <-------- Want this to be 
1004_05
    <tagName>GR_AGE.1</tagName>
    <flags>1</flags>
    <format>4096</format>
    <value>4 Yrs.</value>
  </form>
</Report>
*******************************************************

Everything else works fine.

What should that line be?  Do I need to do another match and template?

Thanks,

Tom 




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent