This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: processing-instruction()


Thanks, Joerg. I still have the PIs in the output with the following
Stylesheet. I do have the
specific matchings for the PIs. I'm using xalan. Are PIs in node()? My
impression from a book is that node() only matches elements. 

Thanks.

Peiyun

  <xsl:template match="/">     
     <equations>
        <xsl:for-each select="//equation|//inlineequation" >
          <xsl:copy>
             <xsl:copy-of select="@*" />
             <xsl:apply-templates select="node()" />
          </xsl:copy>
        </xsl:for-each>
     </equations>       
  </xsl:template>
  
  <xsl:template match="node()">
       <xsl:copy>
            <xsl:copy-of select="@*" />
            <xsl:apply-templates select="node()" />
       </xsl:copy>
  </xsl:template>
  
  <xsl:template match="processing-instruction('Eqn')">
      <!-- do nothing now -->
  </xsl:template>
  
  <xsl:template match="processing-instruction('Pub')">
      <!-- do nothing now, but want to keep -->
  </xsl:template>
  

-----Original Message-----
From: Joerg Heinicke [mailto:joerg.heinicke@gmx.de]
Sent: Wednesday, July 31, 2002 10:17 AM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] processing-instruction()


processing-instruction() is included in node(), so if you do

<xsl:apply-templates select="node()" />

and if you have a template matching on node(), you don't need the special 
<xsl:apply-templates/> and <xsl:template/> for the processing instructions. 
If you remove every pi-stuff they will be simply copied to output. If you 
add a template matching on the special processing-instruction, this one will

not be copied to output.

Regards,

Joerg

Jiang, Peiyun wrote:
> What's wrong?
> 
> I'm trying to match processing instructions. I want to get rid of the
<?Eqn
> TeX input="\hskip -32pt\hbox to32pt{[6]}"?> part in the source file. 
> 
> Source file: <equation> and <inlineequation> mixed with text and markup.
> XSLT: I match every <equation> and <inlineequation> and copy recursively
any
> attributes and elements. I match processing instructions and remove them
all
> (but I want to keep some of them later).
> output: no processing instructions removed.
> 
> Am I doing the right thing to match the processing instructions? See
> stylesheet below.
> 
> Thanks.
> 
> Peiyun
> 
> 
> -----------------------
> source: equations mixed with text.
> <doc>Text before equations.
> <inlineequation id="il1"><?Pub Eqn?>
> <f><rm><a><ac>CV</ac><ac>&d4;</ac></a><fen lp="par"><rm><g>q</g></rm>
> <rp post="par"/></fen></rm></f>
> </inlineequation>
> More text and other <tags></tags> more text.
> <equation id="eqn006"><?Pub Eqn?>
> <fd><fl><rm><?Eqn TeX input="\hskip -32pt\hbox to32pt{[6]}"?></rm>
> <rm>Prob<fen lp="par"><mit>m<inf>ij</inf>&vbm0;R<inf>j</inf><rm>,</rm>
> <g>p</g><inf>ij</inf></mit><rp post="par"/></fen>=<fen lp="par"><stk>
>
<lyr><mit>Rj</mit></lyr><lyr><it><mit>m<inf>ij</inf></mit></it></lyr></stk>
> <rp post="par"/></fen><g>p</g><sup><mit>m<inf>ij</inf></mit></sup><inf>
> <mit>ij</mit></inf></rm><fen lp="par">1-<g>p</g><inf>ij</inf><rp
> post="par"/></fen>
> <sup>R<inf>j</inf>-m<inf>ij</inf></sup></fl></fd>
> </equation>
> <moretext></moretext> more text.
> </doc>
> -----------------------
> output: equations without text.
> 
> <equations>
> <inlineequation id="il1"><?Pub Eqn?>
> <f><rm><a><ac>CV</ac><ac>&d4;</ac></a><fen lp="par"><rm><g>q</g></rm>
> <rp post="par"/></fen></rm></f>
> </inlineequation>
> <equation id="eqn006"><?Pub Eqn?>
> <fd><fl><rm><?Eqn TeX input="\hskip -32pt\hbox to32pt{[6]}"?></rm>
> <rm>Prob<fen lp="par"><mit>m<inf>ij</inf>&vbm0;R<inf>j</inf><rm>,</rm>
> <g>p</g><inf>ij</inf></mit><rp post="par"/></fen>=<fen lp="par"><stk>
>
<lyr><mit>Rj</mit></lyr><lyr><it><mit>m<inf>ij</inf></mit></it></lyr></stk>
> <rp post="par"/></fen><g>p</g><sup><mit>m<inf>ij</inf></mit></sup><inf>
> <mit>ij</mit></inf></rm><fen lp="par">1-<g>p</g><inf>ij</inf><rp
> post="par"/></fen>
> <sup>R<inf>j</inf>-m<inf>ij</inf></sup></fl></fd>
> </equation>
> </equations>
> -----------------------
> stylesheet:
>   <xsl:template match="/">     
>      <equations>
>         <xsl:for-each select="//equation|//inlineequation" >
>           <xsl:copy>
>              <xsl:copy-of select="@*" />
>              <xsl:apply-templates select="node()" />
>              <xsl:apply-templates select="processing-instruction('Eqn')"
/>
>              <xsl:apply-templates select="processing-instruction('Pub')"
/>
>           </xsl:copy>
>         </xsl:for-each>
>      </equations>       
>   </xsl:template>
>   
>   <xsl:template match="node()">
>        <xsl:copy>
>             <xsl:copy-of select="@*" />
>             <xsl:apply-templates select="node()" />
>              <xsl:apply-templates select="processing-instruction('Eqn')"
/>
>              <xsl:apply-templates select="processing-instruction('Pub')"
/>
>        </xsl:copy>
>   </xsl:template>
>   
>   <xsl:template match="processing-instruction('Eqn')">
>       <!-- do nothing now -->
>   </xsl:template>
>   
>   <xsl:template match="processing-instruction('Pub')">
>       <!-- do nothing now, but want to keep -->
>   </xsl:template>
>  
> -----------------------
> desired output: (inline)equations only and without <?Eqn ...?> 
> <equations>
> <inlineequation id="il1"><?Pub Eqn?>
> <f><rm><a><ac>CV</ac><ac>&d4;</ac></a><fen lp="par"><rm><g>q</g></rm>
> <rp post="par"/></fen></rm></f>
> </inlineequation>
> <equation id="eqn006"><?Pub Eqn?>
> <fd><fl><rm></rm>
> <rm>Prob<fen lp="par"><mit>m<inf>ij</inf>&vbm0;R<inf>j</inf><rm>,</rm>
> <g>p</g><inf>ij</inf></mit><rp post="par"/></fen>=<fen lp="par"><stk>
>
<lyr><mit>Rj</mit></lyr><lyr><it><mit>m<inf>ij</inf></mit></it></lyr></stk>
> <rp post="par"/></fen><g>p</g><sup><mit>m<inf>ij</inf></mit></sup><inf>
> <mit>ij</mit></inf></rm><fen lp="par">1-<g>p</g><inf>ij</inf><rp
> post="par"/></fen>
> <sup>R<inf>j</inf>-m<inf>ij</inf></sup></fl></fd>
> </equation>
> </equations>
> -----------------------
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


-- 

System Development
VIRBUS AG
Fon  +49(0)341-979-7419
Fax  +49(0)341-979-7409
joerg.heinicke@virbus.de
www.virbus.de


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]