|
| Loop through children |
 |
Thu, 27 Mar 2008 15:02:43 -070 |
If I have the following xml:
<?xml version="1.0" encoding="utf-8"?>
<REPORT VERSION="1.10" FILENUM="" DESCRIPTION="Form
Utility XML: 3/18/2008
12:27:13 PM" MAJORFORM="1004">
<ORDER></ORDER>
<TRACKING></TRACKING>
<FORMS>
<FORM NUM="1" FORMCODE="1004" SECCODE="1"
DESC="" MAJOR="True" >
<FIELDS>
<OTHERFILENUMBER>692</OTHERFILENUMBER>
<FNMA_FILENUMBER>693</FNMA_FILENUMBER>
<SUBPROPADDRESS>3</SUBPROPADDRESS>
</FIELDS>
<FORMPHOTOS></FORMPHOTOS>
<ATTACHMENTS></ATTACHMENTS>
</FORM>
</FORMS>
</REPORT>
I have can have about 200 nodes under the <FIELDS> node.
Each node has it's own name.
What I am looking for is to build an style sheet that loops through the
children and creates a set of nodes that would look something like:
<?xml version="1.0" encoding="utf-8"?>
<REPORT>
<form>
<sectionNumber>1</sectionNumber>
<primary>True</primary>
<formName>1004</formName>
<tagName>OTHERFILENUMBER</tagName>
<value>692</value>
<form>
<form>
<sectionNumber>1</sectionNumber>
<primary>True</primary>
<formName>1004</formName>
<tagName>FNMA_FILENUMBER</tagName>
<value>693</value>
<form>
<form>
<sectionNumber>1</sectionNumber>
<primary>True</primary>
<formName>1004</formName>
<tagName>SUBPROPADDRESS</tagName>
<value>SUBPROPADDRESS</value>
<form>
</REPORT>
The xslt file I was working with is:
<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="/*">
<root_node>
<xsl:apply-templates>
<xsl:sort select="form/@Major"
order="descending"/>
</xsl:apply-templates>
</root_node>
</xsl:template>
<xsl:template match="FIELDS">
<form>
<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>
</form>
</xsl:template>
</xsl:stylesheet>
This almost works for the first one but I need it to loop through each tag.
I tried using <xsl:for-each...> but couldn't seem to get it to work.
I also get FIELDS in the <tagName> tag. That is because name() is using
the
name of the current tag (I suppose) that I found in the match.
I can't seem to get the <xsl:copy> to work for my root node (to get the
name
of the Root Node). Actually it works, but it puts
(xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance) in the <form> tag.
But the root node is <REPORT> as I wanted.
This is when I do it like this.
<xsl:copy>
<xsl:apply-templates>
<xsl:sort select="form/@Major"
order="descending"/>
</xsl:apply-templates>
</xsl:copy>
If I do it as above, it puts tne xmlns stuff in the root node, which is now
<root_node
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">. How do I
fix that?
Thanks,
Tom
|
| Post Reply
|
| Re: Loop through children |
 |
Thu, 27 Mar 2008 16:11:44 -070 |
I tried this following and it only gives me the first child and FIELDS for
the tag name:
<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>
The result is:
<?xml version="1.0" encoding="utf-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tagName>FIELDS</tagName>
<value>692</value>
</form>
Thanks,
Tom
"tshad" <tshad@dslextreme.com> wrote in message
news:el86taFkIHA.4356@TK2MSFTNGP02.phx.gbl...
> If I have the following xml:
>
> <?xml version="1.0" encoding="utf-8"?>
> <REPORT VERSION="1.10" FILENUM=""
DESCRIPTION="Form Utility XML: 3/18/2008
> 12:27:13 PM" MAJORFORM="1004">
> <ORDER></ORDER>
> <TRACKING></TRACKING>
> <FORMS>
> <FORM NUM="1" FORMCODE="1004"
SECCODE="1" DESC="" MAJOR="True" >
> <FIELDS>
> <OTHERFILENUMBER>692</OTHERFILENUMBER>
> <FNMA_FILENUMBER>693</FNMA_FILENUMBER>
> <SUBPROPADDRESS>3</SUBPROPADDRESS>
> </FIELDS>
> <FORMPHOTOS></FORMPHOTOS>
> <ATTACHMENTS></ATTACHMENTS>
> </FORM>
> </FORMS>
> </REPORT>
>
> I have can have about 200 nodes under the <FIELDS> node.
>
> Each node has it's own name.
>
> What I am looking for is to build an style sheet that loops through the
> children and creates a set of nodes that would look something like:
>
> <?xml version="1.0" encoding="utf-8"?>
> <REPORT>
> <form>
> <sectionNumber>1</sectionNumber>
> <primary>True</primary>
> <formName>1004</formName>
> <tagName>OTHERFILENUMBER</tagName>
> <value>692</value>
> <form>
> <form>
> <sectionNumber>1</sectionNumber>
> <primary>True</primary>
> <formName>1004</formName>
> <tagName>FNMA_FILENUMBER</tagName>
> <value>693</value>
> <form>
> <form>
> <sectionNumber>1</sectionNumber>
> <primary>True</primary>
> <formName>1004</formName>
> <tagName>SUBPROPADDRESS</tagName>
> <value>SUBPROPADDRESS</value>
> <form>
> </REPORT>
>
> The xslt file I was working with is:
>
> <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="/*">
> <root_node>
> <xsl:apply-templates>
> <xsl:sort select="form/@Major"
order="descending"/>
> </xsl:apply-templates>
> </root_node>
> </xsl:template>
> <xsl:template match="FIELDS">
> <form>
> <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>
> </form>
> </xsl:template>
> </xsl:stylesheet>
>
> This almost works for the first one but I need it to loop through each
> tag. I tried using <xsl:for-each...> but couldn't seem to get it to
work.
>
> I also get FIELDS in the <tagName> tag. That is because name() is
using
> the name of the current tag (I suppose) that I found in the match.
>
> I can't seem to get the <xsl:copy> to work for my root node (to get
the
> name of the Root Node). Actually it works, but it puts
> (xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance) in the <form>
tag.
> But the root node is <REPORT> as I wanted.
>
> This is when I do it like this.
>
> <xsl:copy>
> <xsl:apply-templates>
> <xsl:sort select="form/@Major"
order="descending"/>
> </xsl:apply-templates>
> </xsl:copy>
>
> If I do it as above, it puts tne xmlns stuff in the root node, which is
> now <root_node
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">.
> How do I fix that?
>
> Thanks,
>
> Tom
>
|
| Post Reply
|
| Re: Loop through children |
 |
Fri, 28 Mar 2008 09:10:46 -070 |
"Joe Fawcett" <joefawcett@newsgroup.nospam> wrote in message
news:7704E07A-2DAB-4DF1-BD5B-DF9BBEAEC2EB@microsoft.com...
>
>
> "tshad" <tshad@dslextreme.com> wrote in message
> news:uqbUSBGkIHA.5584@TK2MSFTNGP02.phx.gbl...
>> I tried this following and it only gives me the first child and FIELDS
>> for the tag name:
>>
>> <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>
>>
>> The result is:
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <form
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>> <tagName>FIELDS</tagName>
>> <value>692</value>
>> </form>
>>
>> Thanks,
>>
>> Tom
>> "tshad" <tshad@dslextreme.com> wrote in message
>> news:el86taFkIHA.4356@TK2MSFTNGP02.phx.gbl...
>>> If I have the following xml:
>>>
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <REPORT VERSION="1.10" FILENUM=""
DESCRIPTION="Form Utility XML:
>>> 3/18/2008 12:27:13 PM" MAJORFORM="1004">
>>> <ORDER></ORDER>
>>> <TRACKING></TRACKING>
>>> <FORMS>
>>> <FORM NUM="1" FORMCODE="1004"
SECCODE="1" DESC="" MAJOR="True" >
>>> <FIELDS>
>>> <OTHERFILENUMBER>692</OTHERFILENUMBER>
>>> <FNMA_FILENUMBER>693</FNMA_FILENUMBER>
>>> <SUBPROPADDRESS>3</SUBPROPADDRESS>
>>> </FIELDS>
>>> <FORMPHOTOS></FORMPHOTOS>
>>> <ATTACHMENTS></ATTACHMENTS>
>>> </FORM>
>>> </FORMS>
>>> </REPORT>
>>>
>>> I have can have about 200 nodes under the <FIELDS> node.
>>>
>>> Each node has it's own name.
>>>
>>> What I am looking for is to build an style sheet that loops through
the
>>> children and creates a set of nodes that would look something
like:
>>>
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <REPORT>
>>> <form>
>>> <sectionNumber>1</sectionNumber>
>>> <primary>True</primary>
>>> <formName>1004</formName>
>>> <tagName>OTHERFILENUMBER</tagName>
>>> <value>692</value>
>>> <form>
>>> <form>
>>> <sectionNumber>1</sectionNumber>
>>> <primary>True</primary>
>>> <formName>1004</formName>
>>> <tagName>FNMA_FILENUMBER</tagName>
>>> <value>693</value>
>>> <form>
>>> <form>
>>> <sectionNumber>1</sectionNumber>
>>> <primary>True</primary>
>>> <formName>1004</formName>
>>> <tagName>SUBPROPADDRESS</tagName>
>>> <value>SUBPROPADDRESS</value>
>>> <form>
>>> </REPORT>
>>>
>>> The xslt file I was working with is:
>>>
>>> <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="/*">
>>> <root_node>
>>> <xsl:apply-templates>
>>> <xsl:sort select="form/@Major"
order="descending"/>
>>> </xsl:apply-templates>
>>> </root_node>
>>> </xsl:template>
>>> <xsl:template match="FIELDS">
>>> <form>
>>> <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>
>>> </form>
>>> </xsl:template>
>>> </xsl:stylesheet>
>>>
>>> This almost works for the first one but I need it to loop through
each
>>> tag. I tried using <xsl:for-each...> but couldn't seem to get
it to
>>> work.
>>>
>>> I also get FIELDS in the <tagName> tag. That is because
name() is using
>>> the name of the current tag (I suppose) that I found in the match.
>>>
>>> I can't seem to get the <xsl:copy> to work for my root node
(to get the
>>> name of the Root Node). Actually it works, but it puts
>>> (xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance) in the
<form> tag.
>>> But the root node is <REPORT> as I wanted.
>>>
>>> This is when I do it like this.
>>>
>>> <xsl:copy>
>>> <xsl:apply-templates>
>>> <xsl:sort select="form/@Major"
order="descending"/>
>>> </xsl:apply-templates>
>>> </xsl:copy>
>>>
>>> If I do it as above, it puts tne xmlns stuff in the root node,
which is
>>> now <root_node
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">.
>>> How do I fix that?
>>>
>>> Thanks,
>>>
>>> Tom
>>>
>>
>>
> If you are in the FIELDS template then a for-each on * or apply-template *
> will process the children.
> To get rid of the unwanted namespace declarations use
> exclude-result-prefixes="xsi" in the xsl:stylesheet element.
>
> --
I am still getting the same results as above. Only the first child is being
handled.
I changed the for-each to be:
<xsl:for-each select="*">
And I am still getting the tagName to be FIELDS instead of OTHERFILENUMBER
which is the tag that has the 692, which is displaying.
Thanks,
Tom
>
> Joe Fawcett (MVP - XML)
> http://joe.fawcett.name
|
| Post Reply
|
| Re: Loop through children |
 |
Fri, 28 Mar 2008 09:12:35 -000 |
"tshad" <tshad@dslextreme.com> wrote in message
news:uqbUSBGkIHA.5584@TK2MSFTNGP02.phx.gbl...
> I tried this following and it only gives me the first child and FIELDS for
> the tag name:
>
> <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>
>
> The result is:
>
> <?xml version="1.0" encoding="utf-8"?>
> <form
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <tagName>FIELDS</tagName>
> <value>692</value>
> </form>
>
> Thanks,
>
> Tom
> "tshad" <tshad@dslextreme.com> wrote in message
> news:el86taFkIHA.4356@TK2MSFTNGP02.phx.gbl...
>> If I have the following xml:
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <REPORT VERSION="1.10" FILENUM=""
DESCRIPTION="Form Utility XML:
>> 3/18/2008 12:27:13 PM" MAJORFORM="1004">
>> <ORDER></ORDER>
>> <TRACKING></TRACKING>
>> <FORMS>
>> <FORM NUM="1" FORMCODE="1004"
SECCODE="1" DESC="" MAJOR="True" >
>> <FIELDS>
>> <OTHERFILENUMBER>692</OTHERFILENUMBER>
>> <FNMA_FILENUMBER>693</FNMA_FILENUMBER>
>> <SUBPROPADDRESS>3</SUBPROPADDRESS>
>> </FIELDS>
>> <FORMPHOTOS></FORMPHOTOS>
>> <ATTACHMENTS></ATTACHMENTS>
>> </FORM>
>> </FORMS>
>> </REPORT>
>>
>> I have can have about 200 nodes under the <FIELDS> node.
>>
>> Each node has it's own name.
>>
>> What I am looking for is to build an style sheet that loops through the
>> children and creates a set of nodes that would look something like:
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <REPORT>
>> <form>
>> <sectionNumber>1</sectionNumber>
>> <primary>True</primary>
>> <formName>1004</formName>
>> <tagName>OTHERFILENUMBER</tagName>
>> <value>692</value>
>> <form>
>> <form>
>> <sectionNumber>1</sectionNumber>
>> <primary>True</primary>
>> <formName>1004</formName>
>> <tagName>FNMA_FILENUMBER</tagName>
>> <value>693</value>
>> <form>
>> <form>
>> <sectionNumber>1</sectionNumber>
>> <primary>True</primary>
>> <formName>1004</formName>
>> <tagName>SUBPROPADDRESS</tagName>
>> <value>SUBPROPADDRESS</value>
>> <form>
>> </REPORT>
>>
>> The xslt file I was working with is:
>>
>> <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="/*">
>> <root_node>
>> <xsl:apply-templates>
>> <xsl:sort select="form/@Major"
order="descending"/>
>> </xsl:apply-templates>
>> </root_node>
>> </xsl:template>
>> <xsl:template match="FIELDS">
>> <form>
>> <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>
>> </form>
>> </xsl:template>
>> </xsl:stylesheet>
>>
>> This almost works for the first one but I need it to loop through each
>> tag. I tried using <xsl:for-each...> but couldn't seem to get it
to work.
>>
>> I also get FIELDS in the <tagName> tag. That is because name()
is using
>> the name of the current tag (I suppose) that I found in the match.
>>
>> I can't seem to get the <xsl:copy> to work for my root node (to
get the
>> name of the Root Node). Actually it works, but it puts
>> (xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance) in the
<form> tag.
>> But the root node is <REPORT> as I wanted.
>>
>> This is when I do it like this.
>>
>> <xsl:copy>
>> <xsl:apply-templates>
>> <xsl:sort select="form/@Major"
order="descending"/>
>> </xsl:apply-templates>
>> </xsl:copy>
>>
>> If I do it as above, it puts tne xmlns stuff in the root node, which is
>> now <root_node
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">.
>> How do I fix that?
>>
>> Thanks,
>>
>> Tom
>>
>
>
If you are in the FIELDS template then a for-each on * or apply-template *
will process the children.
To get rid of the unwanted namespace declarations use
exclude-result-prefixes="xsi" in the xsl:stylesheet element.
--
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
|
| Post Reply
|
| Re: Loop through children |
 |
Fri, 28 Mar 2008 14:07:40 -070 |
"tshad" <tshad@dslextreme.com> wrote in message
news:%23sj4u6OkIHA.3400@TK2MSFTNGP03.phx.gbl...
>
>>> <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
|
| Post Reply
|
|
|
|
|
|
|
|
|
|