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

[no subject]

following sibling name
But in all, I would say that if you have any influence on the input
XML, then you should change it. There is nothing in the structures or
attributes that tells that "sb:title" is the child of
"sb:contribution" instead of "sb:authors". This makes a generic
solution impossible.

I have scetched a more generic solution which does not at all do what
you require, but I hope this is some inspiration. Namely, it does not
have an "before host" and "after host" part.

<xsl:template match="root">
  <xsl:apply-templates select="p[bookmark-start]" mode="bookmark"/>
</xsl:template>

<xsl:template match="p" mode="bookmark">
  <xsl:element name="{user-field[1]/@name}">
    <xsl:apply-templates
select="following-sibling::p[preceding-sibling::p[bookmark-start[@id=current(
)/@id]]"
mode="children"/> <!-- Should be a key -->
  </xsl:element>
</xsl:template>

<!-- Should have two templates, one for before host, and one for after host
-->
<xsl:template match="p" mode="children">
  <xsl:element name="{user-field[1]/@name}">
    <xsl:choose>
      <xsl:when test="user-field[position()&gt;1]"> <!-- more
user-fields => leaf -->
        <xsl:apply-templates select="user-field[position()&gt;1]"
mode="leaf"/>
      </xsl:when>
      <xsl:otherwise>
        <!-- More logical children. Caveat about "host" element applies -->
        <xsl:apply-templates
select="following-sibling::p[preceding-sibling::p[bookmark-start[@id=current(
)/@id]]"
mode="children"/>
      </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template match="user-field" mode="leaf">
   <xsl:element name="{@name}">
     <xsl:value-of select="following-sibling::user-text"/>
  </xsl:element>
</xsl:template>

I hope this is some help for your problem.
Regards,
Ragulf Pickaxe :-)

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.