RE: [xsl] XSL omit part of a text inside TAG

Subject: RE: [xsl] XSL omit part of a text inside TAG
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 7 Mar 2008 11:32:35 -0000
Why are you doing this in the template for VisualObject rather than the
template for FontFace? Your VisualObject should be doing apply-templates on
its children.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: buddhi [mailto:buddhi@xxxxxxxxxxxxxxxxxxx] 
> Sent: 07 March 2008 11:26
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] XSL omit part of a text inside TAG
> 
> Hi,
> 
> Now following XSL works for me, but I am loosing children 
> from <visualObjects> tag, I am only getting <fontface> 
> inside... Is there anyway to get other tags (unmodified)
> 
> - Buddhi -
> 
> My XSL:
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>     <xsl:template match="/">
>         <xsl:apply-templates select="*"/>
>     </xsl:template>
>     <xsl:template match="@* | node()">
>     <xsl:copy>
>       <xsl:apply-templates select="@* | node()"/>
>     </xsl:copy>
>     </xsl:template>
>    <xsl:template match="VisualObject">
>         <xsl:choose>
>             <xsl:when test="@xsi:type='CBarCode'">
>                 <xsl:copy>
>                     <FontFace>
>                         <xsl:variable name="fontface" select 
> = 'FontFace'/>
>                         <xsl:call-template name="while">
>                             <xsl:with-param name="foo" 
> select="$fontface"/>
>                         </xsl:call-template>
>                     </FontFace>
>                 </xsl:copy>
>             </xsl:when>
>             <xsl:otherwise>
>                 <xsl:copy-of select="."/>
>             </xsl:otherwise>
>         </xsl:choose>
>     </xsl:template>
> 
> <xsl:template name="while">
>     <xsl:param name="foo"/>
>     <xsl:choose>
>         <xsl:when test="contains($foo,'\')">
>             <xsl:variable name="newfoo" 
> select="substring-after($foo,'\')"/>
>             <xsl:call-template name="while">
>                 <xsl:with-param name="foo" select="$newfoo"/>
>             </xsl:call-template>
>         </xsl:when>
>         <xsl:otherwise>
>             <xsl:value-of select="$foo"/>
>         </xsl:otherwise>
>     </xsl:choose>
> </xsl:template>
> </xsl:stylesheet>
> 
> 
> 
> 
> Hi all,
> 
> Following is my xml file,
> 
> <?xml version="1.0"?>
> <FileSerializeWrapper xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>   <Unit>Inches</Unit>
>   <PanPoint>
>     <X>0</X>
>     <Y>0</Y>
>   </PanPoint>
>   <ZoomFactor>0</ZoomFactor>
>   <FlowData>
>     <VisualObject xsi:type="CProjectEx">
>       <maxQSwitch>500</maxQSwitch>
>       <Address>Laser Job</Address>
>     </VisualObject>
>     <TrueSideChildren>
>       <FlowData>
>         <VisualObject xsi:type="CLayerEx">
>           <maxQSwitch>500</maxQSwitch>
>           <Address>Laser Job.Layer</Address>
>           <Name>Layer</Name>
>           <Override>true</Override>
>         </VisualObject>
>         <FlowType>Layer</FlowType>
>         <TrueSideChildren>
>           <FlowData>
>             <VisualObject xsi:type="CBarCode">
>               <maxQSwitch>133</maxQSwitch>
>               <Address>Laser Job.Layer.Barcode1</Address>
>               <Name>Barcode1</Name>
>               <Width>2.8144999999999953</Width>
>               <DataString>CODE 39 TEXT</DataString>
>               <EncodeData>
>                 <dBCHeight>0.5</dBCHeight>
>                 <dBCWidth>2.8144999999999953</dBCWidth>
>                 <szQRFmtAppIndicator />
>               </EncodeData>
>               <EnableHRText>true</EnableHRText>
>               <FontFace>D:\Work\Phase
> III\Executables\Fonts\TIMESNRO.FNT</FontFace>
>               <IsBold>false</IsBold>
>               <IsItalic>false</IsItalic>
>               <FontHeight>0.08</FontHeight>
>               <FontGap>0.02</FontGap>
>               <HRTextAtTop>false</HRTextAtTop>
>             </VisualObject>
>             <ShapeName />
>           </FlowData>
>         </TrueSideChildren>
>         <FalseSideChildren />
>         <IsExpanded>true</IsExpanded>
>         <EventDataCode />
>         <ShapeName />
>       </FlowData>
>     </TrueSideChildren>
>     <FalseSideChildren />
>     <EventDataCode />
>     <ShapeName />
>   </FlowData>
> </FileSerializeWrapper>
> 
> Actually I want ONLY to remove a path from this tag,
> 
> <FontFace>D:\Work\Phase III\Executables\Fonts\TIMESNRO.FNT</FontFace>
> 
> In final xml file I want to appear it as this,
> 
> <FontFace>TIMESNRO.FNT</FontFace>
> 
> I tried so many ways, since I couldn't find mid,left, right 
> string functions with xsl, I couldn't get the expected out 
> put. Following is my xsl file. Can anyone please tell me how 
> to do that.
> 
> My XSL file :
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>     <xsl:template match="/">
>         <xsl:apply-templates select="*"/>
>     </xsl:template>
>     <xsl:template match="@* | node()">
>     <xsl:copy>
>       <xsl:apply-templates select="@* | node()"/>
>     </xsl:copy>
>     </xsl:template>
>     <xsl:template match="VisualObject">
>         <xsl:choose>
>             <xsl:when test="@xsi:type='CBarCode'">
>                 <xsl:copy>
>                 </xsl:copy>
>             </xsl:when>
>             <xsl:otherwise>
>                 <xsl:copy-of select="."/>
>             </xsl:otherwise>
>         </xsl:choose>
>     </xsl:template>
> </xsl:stylesheet>
> 
> - Regards
> 
> - Buddhi -

Current Thread