Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Thu, 22 May 2008 22:56:00 -0700,    group: microsoft.public.xsl        back       


Nodes inside nodes   
I have an xsl file that worked fine until my tag node, which I am looking 
for to get my values had some nested tags.

At the moment the file I have now 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/@primary" order="descending"/>
   </xsl:apply-templates>
  </root_node>
 </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:value-of select="ancestor::form/@name"/>
   </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="."/>
   </value>
  </form>
 </xsl:template>
 <xsl:template match="heading">
  <heading>
   <xsl:value-of select="."/>
  </heading>
 </xsl:template>
 <xsl:template match="attachments/attachment">
    <attachment>
      <key>
        <xsl:value-of select="@key"/>
      </key>
      <type>
        <xsl:value-of select="@type"/>
      </type>
      <label>
        <xsl:value-of select="@label"/>
      </label>
      <imageFormat>
        <xsl:value-of select="image/binary/@format"/>
      </imageFormat>
      <imageText>
        <xsl:value-of select="image/binary/text()"/>
      </imageText>
      <thumbnailFormat>
        <xsl:value-of select="thumbnail/binary/@format"/>
      </thumbnailFormat>
      <thumbnailImage>
        <xsl:value-of select="thumbnail/binary/text()"/>
      </thumbnailImage>
  <sourceFormat>
   <xsl:value-of select="source/@format"/>
  </sourceFormat>
  <sourceKey>
   <xsl:value-of select="source/@key"/>
  </sourceKey>
  <sourceText>
   <xsl:value-of select="source/binary/text()"/>
  </sourceText>
 </attachment>
  </xsl:template>
</xsl:stylesheet>
*********************************************

If I have the following xml file:
*********************************************
<?xml version="1.0" encoding="utf-8"?>
<ACI-Report>
  <appr>
    <data>
      <form name="land2" primary="true">
        <section type="options" number="0" />
        <section type="subject" number="0">
          <tag name="OWNER.1" flags="4" format="4096">CA</tag>
          <tag name="GS_COMMENTS.1" flags="4" format="4096">See Attached 
Addendum
                                       <addendum>
                                              <heading>Comments on Sales 
Comparison</heading>
                                               <body>SALES COMPARISON 
COMMENTS: The sales
                                                            comparison 
approach is based
                                                           on the principle 
of substitution
                                                </body>
                                        </addendum>
          </tag>
          <tag name="PHOTO_FILE.5" flags="4096" 
format="12288">attachment[5]</tag>
        </section>
      </form>
    </data>
  </appr>
</ACI-Report>
*********************************************

The indented section is the one causing me a problem.  It is inside the 
"tag" tags

The result of this is:

*******************************************
<?xml version="1.0" encoding="utf-8"?>
<root_node xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <form>
    <sectionNumber>0</sectionNumber>
    <primary>true</primary>
    <formName>land2</formName>
    <tagName>OWNER.1</tagName>
    <flags>4</flags>
    <format>4096</format>
    <value>CA</value>
  </form>
  <form>
    <sectionNumber>0</sectionNumber>
    <primary>true</primary>
    <formName>land2</formName>
    <tagName>GS_COMMENTS.1</tagName>
    <flags>4</flags>
    <format>4096</format>
    <value>See Attached Addendum

            Comments on Sales Comparison
             SALES COMPARISON COMMENTS: The sales comparison approach is 
based
               on the principle of substitution


          </value>
  </form>
  <form>
    <sectionNumber>0</sectionNumber>
    <primary>true</primary>
    <formName>land2</formName>
    <tagName>PHOTO_FILE.5</tagName>
    <flags>4096</flags>
    <format>12288</format>
    <value>attachment[5]</value>
  </form>
</root_node>
*******************************************

It is almost correct, except for the GS_COMMENTS section because of the 
embedded tags.  The value should just be "See Attached Addendum"

What I would like to do is take the inside tags:

                                       <addendum>
                                              <heading>Comments on Sales 
Comparison</heading>
                                               <body>SALES COMPARISON 
COMMENTS: The sales
                                                            comparison 
approach is based
                                                           on the principle 
of substitution
                                                </body>
                                        </addendum>

and have another set of forms, something like:
****************************************
  <form>
    <sectionNumber>0</sectionNumber>
    <primary>false</primary>
    <formName>addendum</formName>
    <tagName>Comments on Sales Comparison</tagName>
    <flags>0</flags>
    <format>0format>
    <value>SALES COMPARISON COMMENTS: The sales
                                                            comparison 
approach is based
                                                           on the principle 
of substitution
     </value>
  </form>
*****************************************

Where I put the addendum as the the FormName, the text between "heading" 
tags into the tagName field and the text between the "body" into the value 
field.

How would I do this and have it not show as part of the GS_COMMENTS.1 
section?

Thanks,

Tom
date: Thu, 22 May 2008 22:56:00 -0700   author:   tshad

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us