Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • punzo 2 posts 22 karma points
    Nov 24, 2009 @ 11:20
    punzo
    0

    Headlines: separate number and title with same parent

    Can anyone give me a solution to the following problem?

    <root>
       <elem1>
          <titel><bold>1.<tab/>The text <italic>of the</italic> headline</bold></titel>
       </elem1>
       <par>...</par>
       <par/>
    </root>

    Should become the following structure (attention: double bold-element):

    <root>
       <elem1>
          <titel>
             <nummer><bold>1.</bold></nummer>
             <text><bold>The text <italic>of the </italic> headline</bold></text>
          </titel>
       </elem1>
    </root>

    Thanks a lot!

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 24, 2009 @ 13:32
    Chriztian Steinmeier
    1

    You can use this as a starting point (though very specific to your case):

       <xsl:template match="elem1">
            <elem1>
                <titel>
                    <nummer>
                        <bold>
                            <xsl:value-of select="titel/bold/text()[1]" />
                        </bold>
                    </nummer>
                    <text>
                        <bold>
                            <xsl:apply-templates select="titel/bold/tab/following-sibling::text() | titel/bold/tab/following-sibling::*" />
                        </bold>
                    </text>
                </titel>
            </elem1>
        </xsl:template>
    
        <xsl:template match="*">
            <xsl:copy>
                <xsl:apply-templates />
            </xsl:copy>
        </xsl:template>
    
    /Chriztian
  • punzo 2 posts 22 karma points
    Nov 24, 2009 @ 13:59
    punzo
    0

    Thanks a lot Chriztian,

    but this is not the whole solution for me, beacause I might have different cases.

    Elements like <bold>, <italic> can be there or not. So the only thing I really know is that the element <title> exists and that it has an <tab/>-element or not.

    This means, that I might have following cases:

    <title>1.<tab/>The headline-text</title>

    <title>The headline-text</title>

    <title><italic>1.</italic><tab/>the headline-text</title>

    <title><emph>1.<tab/>the headline-text</emph></title>

    <title>1.<footnote>annotaion</footnote><tab/>the headline-text</title>

    and so on...

    So I would like to have all elements "between" <title>...<tab/> into the resulting element <nummer>, and all the rest into <text>, but: with all possible parents.

     

    punzo

Please Sign in or register to post replies

Write your reply to:

Draft