473,513 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why do I get "2" and "2-2" in output?

11 New Member
XSL:

Expand|Select|Wrap|Line Numbers
  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2.     xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" version="1.0">
  3.  
  4.     <xsl:output method="xml" encoding="utf-8" indent="no"/>
  5.  
  6.  
  7.     <xsl:template match="w:p[ancestor::w:tbl[not(ancestor::w:tbl)]]">
  8.             <xsl:if test="count(w:smartTag[@w:element='livetechdocs'])=0">
  9.                 <xsl:variable name="n">
  10.                     <xsl:number from="w:tbl" level="any"/>
  11.                 </xsl:variable>
  12. <xsl:message><xsl:value-of select="@XID"/> ----- <xsl:value-of select="$n"/></xsl:message>
  13.                 <xsl:if test="$n = 1">
  14.                     <w:smartTag w:uri="http://schemas.openxmlformats.org/2006/smarttags"
  15.                         w:element="livetechdocs"> </w:smartTag>
  16.                 </xsl:if>
  17.             </xsl:if>
  18.     </xsl:template>
  19.  
  20. </xsl:stylesheet>
  21.  

XML:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <w:document  xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" >
  3.     <w:body>
  4.         <w:p XID="1">
  5.         </w:p>
  6.  
  7.  
  8. <w:tbl>
  9.         <w:tbl>
  10.             <w:tr>
  11.                 <w:tc>
  12.                     <w:p XID="2">
  13.                     </w:p>
  14.                     <w:p XID="2-2">
  15.                     </w:p>
  16.                 </w:tc>
  17.             </w:tr>
  18.         </w:tbl>
  19. </w:tbl>
  20.         <w:p XID="3">
  21.         </w:p>
  22.  
  23.         <w:tbl>
  24.             <w:tr>
  25.                 <w:tc>
  26.                     <w:p XID="4">
  27.                     </w:p>
  28.                 </w:tc>
  29.             </w:tr>
  30.             <w:tr>
  31.                 <w:tc>
  32.                     <w:p XID="5">
  33.                     </w:p>
  34.                 </w:tc>
  35.             </w:tr>
  36.         </w:tbl>
  37.  
  38.     </w:body>
  39. </w:document>

My XSL isn't supposed to output w:p inside of w:tbl when this w:tbl has another w:tbl across his ancestors. But it does. How should I change it to produce correct output?
Apr 15 '10 #1
2 1584
jkmyoung
2,057 Recognized Expert Top Contributor
Your xpath looks for any ancestor w:tbl that doesn't have an ancestor w:tbl. BUT, there are 2 ancestor w:tbl. It rejects the first one, but accepts the second one (which doesn't have an ancestor w:tbl of it's own.)

Uhhh.. try instead:
w:p[ancestor::w:tbl[1][not(ancestor::w:tbl)]]">

Let me know if that doesn't work.
Apr 15 '10 #2
senglory
11 New Member
Another option is

Expand|Select|Wrap|Line Numbers
  1. w:p[count(ancestor::w:tbl) = 1]
Apr 15 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
8120
by: Mark Wilson CPU | last post by:
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: -------------------------------------...
3
2771
by: edgekaos | last post by:
Is method 2 valid? Method 1: wstring input = L"STRING"; wstring output = input; transform(output.begin(), output.end(), output.begin(), towupper); Method 2: wstring input = L"STRING";...
4
15037
by: Kevin Mansel via .NET 247 | last post by:
Ok, basically this is my problem. I'm building a console app tocall a dos program. So i'm using the Shell command to call theprogram, now depending on what happens, I want to read theoutput that...
24
2665
by: kalamantina | last post by:
#include "stdafx.h" #include <stdio.h> #define output( x ) printf( #x "\r\n" );fflush( stdout ) class CMyBase { public: CMyBase() { output( CMyBase() ); f(*this);
0
2051
by: newbie | last post by:
i'm a newbie of c language. can anyone help me to implement the code so that I can get the ciphertext from the output. thanks. #ifndef _3DES_H #define _3DES_H #ifndef uint8 #define uint8 ...
32
2737
by: spibou | last post by:
Is the output of the C preprocessor deterministic ? What I mean by that is , given 2 compilers which conform to the same standard, will their preprocessors produce identical output given as input...
3
2613
by: MatsL | last post by:
Hi, This is seriously driving me crazy, could anyone explain to me why neither of these doesn't produce XHTML compliant output (it is being called in Render() btw): output.WriteLine("<img...
3
4641
by: undshan | last post by:
I am writing a code that needs to open a file, create an output file, run through my function, prints the results to the output file, and closes them within a loop. Here is my code: #include...
5
3313
by: amit.uttam | last post by:
Hey everyone, I've recently jumped big time into python and I'm working on a software program for testing automation. I had a question about proper logging of output. What I would like is: 1....
2
3358
by: gabosom | last post by:
Hi! I've been breaking my head trying to get the output variables from my Stored Procedure. This is my SP code CREATE PROCEDURE GetKitchenOrderDetail( @idService int, --outPut Variables ...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.