Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Loop through children

From: "tshad" <tshad@----------.--->
To: NULL
Date: 3/28/2008 2:08:00 PM


"tshad" <tshad@d...> wrote in message 
news:%23sj4u6OkIHA.3400@T......
>
>>> <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>
>>>    <xsl:sort select="form/@Major" order="descending"/>
>>>   </xsl:apply-templates>
>>>  </xsl:copy>
>>> </xsl:template>
>>> <xsl:template match="FIELDS">
>>>  <form>
>>>   <xsl:for-each select="child">
>>>    <sectionNumber>
>>>     <xsl:value-of select="ancestor::FORM/@SECCODE"/>
>>>    </sectionNumber>
>>>    <primary>
>>>     <xsl:value-of select="ancestor::FORM/@MAJOR"/>
>>>    </primary>
>>>    <formName>
>>>     <xsl:value-of select="ancestor::FORM/@FORMCODE"/>
>>>    </formName>
>>>    <tagName>
>>>     <xsl:value-of select="name()"/>
>>>    </tagName>
>>>    <value>
>>>     <xsl:value-of select="*"/>
>>>    </value>
>>>   </xsl:for-each>
>>>  </form>
>>> </xsl:template>
>>> </xsl:stylesheet>
>>>

My mistake.  I was pointing at the old sheet and not my new changes.

This sheet works fine.

<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>
    <xsl:sort select="form/@Major" order="descending"/>
   </xsl:apply-templates>
  </xsl:copy>
 </xsl:template>
 <xsl:template match="FIELDS">
  <form>
   <xsl:for-each select="*">
    <sectionNumber>
     <xsl:value-of select="ancestor::FORM/@SECCODE"/>
    </sectionNumber>
    <primary>
     <xsl:value-of select="ancestor::FORM/@MAJOR"/>
    </primary>
    <formName>
     <xsl:value-of select="ancestor::FORM/@FORMCODE"/>
    </formName>
    <tagName>
     <xsl:value-of select="name()"/>
    </tagName>
    <value>
     <xsl:value-of select="text()"/>
    </value>
   </xsl:for-each>
  </form>
 </xsl:template>
</xsl:stylesheet>

What is strange, as I mentioned before, was that the xmlns:xsi line is on 
the "form" tag and not the root tag.

<?xml version="1.0" encoding="utf-8"?>
<FORMS>
  <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <sectionNumber>1</sectionNumber>
    <primary>True</primary>
    <formName>1004</formName>
    <tagName>OTHERFILENUMBER</tagName>
    <value>692</value>
    <sectionNumber>1</sectionNumber>
    <primary>True</primary>
    <formName>1004</formName>
    <tagName>FNMA_FILENUMBER</tagName>
    <value>693</value>
    <sectionNumber>1</sectionNumber>
    <primary>True</primary>
    <formName>1004</formName>
    <tagName>SUBPROPADDRESS</tagName>
    <value>3</value>
  </form>
</FORMS>

If I chang the script from:

  <xsl:copy>

to

<FORMS>

Then it puts the xmlns:xsi line there.

Why is that?

As you say, I can put exclude-result-prefixes="xsi" in the xsl:stylesheet 
element and it disappears.  Is it something that should be there?

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