![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Loop through children [Thread Next] Re: Loop through childrenTo: 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
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
