[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

not a well-formed output XML

Subject: not a well-formed output XML
From: RQamar <qamar_rahil@xxxxxxxxxxx>
Date: Wed, 02 Mar 2005 11:47:59 +0000
xsl if test xml
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="{@id}" type="none">
<xsl:value-of select="@name"/>
</PrimeConcept>
<xsl:if test="following-sibling::DEFCONCEPT[@name = $constraint] | preceding-sibling::DEFCONCEPT[@name=$constraint]">
<xsl:for-each select="following-sibling::DEFCONCEPT[@name = $constraint] | preceding-sibling::DEFCONCEPT[@name=$constraint]">
<SubConcepts>
<SubConcept id="{@id}" name="{@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[@id=$conceptRef] | preceding::DEFCONCEPT[@id=$conceptRef]">
<xsl:if test="IMPLIES/SOME | IMPLIES/ALL | CHILD">
<SubConcept id="{@id}" name="{@name}">
<xsl:if test="CHILD">
<xsl:for-each select="CHILD/CONCEPT">
<ChildConcept ref="{@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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.