xsl-list
[Top] [All Lists]

not a well-formed output XML

2005-03-02 04:47:59
Hi

Im really tired of trying to make my XML document well-formed as well as enable recursive looping until no more 'children' or 'implications' of a particular element are found, so would appreciate any help. The output that I receive is correct (it does all the right extraction) though.

My output XML file (after XSLT processing) is of the form

----------------
<Top>
  <PrimeConcept id="0001" type="none">A</PrimeConcept>
  <SubConcepts>
     <SubConcept id="0002" name="A1">
       <Value ref="0003">hasProperty1 AB</Value>
       <Value ref="0004">hasProperty2 XY</Value>

       <SubConcept id="0004" name="XY">
           <ChildConcept ref="0005">XY1</ChildConcept>
           <SubConcept id="0005" name="XY1">
              <ChildConcept ref="0007">XY11</ChildConcept>
              <ChildConcept ref="0008">XY12</ChildConcept>
           </SubConcept>
           <ChildConcept ref="0006">XY2</ChildConcept>
        </SubConcept>

   </SubConcept>
  </SubConcepts>
</Top>
----------------

As you can see its an utterly loopy XML doc with <SubConcept> inside <SubConcept>. One of the reasons for this is the recursive call to a template until no other 'children' or 'imply' conditions are found. My XSL template blocks are such:

--------------
<xsl:template match="DEFCONCEPT">
    <xsl:if test="@name = $prime">
        <PrimeConcept id="{(_at_)id}" type="none">
            <xsl:value-of select="@name"/>
        </PrimeConcept>
<xsl:if test="following-sibling::DEFCONCEPT[(_at_)name = $constraint] | preceding-sibling::DEFCONCEPT[(_at_)name=$constraint]"> <xsl:for-each select="following-sibling::DEFCONCEPT[(_at_)name = $constraint] | preceding-sibling::DEFCONCEPT[(_at_)name=$constraint]">
               <SubConcepts>
                   <SubConcept id="{(_at_)id}" name="{(_at_)name}">
                       <xsl:if test="IMPLIES/SOME | IMPLIES/ALL">
<xsl:for-each select="IMPLIES/SOME | IMPLIES/ALL"> <Value type="TEXT" ref="{CONCEPT/@ref}"><xsl:value-of select="(OBJECT-SLOT|self::*[not(OBJECT-SLOT)]/DATA-SLOT)/@name"/>&#160;<xsl:value-of select="CONCEPT/@name"/></Value> <xsl:call-template name="impliedRestrictions"> <xsl:with-param name="conceptRef" select="CONCEPT/@ref"/>
                               </xsl:call-template>
                           </xsl:for-each>
                       </xsl:if>
                   </SubConcept>
               </SubConcepts>
           </xsl:for-each>
       </xsl:if>
</xsl:if> </xsl:template>

<xsl:template name="impliedRestrictions">
<xsl:param name="conceptRef"/> <xsl:for-each select="following::DEFCONCEPT[(_at_)id=$conceptRef] | preceding::DEFCONCEPT[(_at_)id=$conceptRef]">
       <xsl:if test="IMPLIES/SOME | IMPLIES/ALL | CHILD">
           <SubConcept id="{(_at_)id}" name="{(_at_)name}">
               <xsl:if test="CHILD">
                   <xsl:for-each select="CHILD/CONCEPT">
<ChildConcept ref="{(_at_)ref}"><xsl:value-of select="@name"/></ChildConcept>
                       <xsl:call-template name="impliedRestrictions">
<xsl:with-param name="conceptRef" select="@ref"/>
                       </xsl:call-template>
                   </xsl:for-each>
               </xsl:if>
               <xsl:if test="IMPLIES/SOME | IMPLIES/ALL">
                   <xsl:for-each select="IMPLIES/SOME | IMPLIES/ALL">
<Value type="TEXT" ref="{CONCEPT/@ref}"><xsl:value-of select="OBJECT-SLOT/@name"/>&#160;<xsl:value-of select="CONCEPT/@name"/></Value>
                       <xsl:call-template name="impliedRestrictions">
<xsl:with-param name="conceptRef" select="CONCEPT/@ref"/>
                       </xsl:call-template>
                   </xsl:for-each>
               </xsl:if>
           </SubConcept>

</xsl:if> </xsl:for-each>
</xsl:template>

--------------

Could someone please help me in trying to obtain an output of the form

----------------

<Top>
  <PrimeConcept id="0001" type="none">A</PrimeConcept>
  <SubConcepts>
     <SubConcept id="0002" name="A1">
       <Value ref="0003">hasProperty1 AB</Value>
       <Value ref="0004">hasProperty2 XY</Value>
   </SubConcept>
   <SubConcept id="0004" name="XY">
           <ChildConcept ref="0005">XY1</ChildConcept>
           <ChildConcept ref="0006">XY2</ChildConcept>
    </SubConcept>
      <SubConcept id="0005" name="XY1">
              <ChildConcept ref="0007">XY11</ChildConcept>
              <ChildConcept ref="0008">XY12</ChildConcept>
     </SubConcept>
  </SubConcepts>
</Top>

---------------

Would truly appreciate any help.

Thanks
Rahil


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>