473,509 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why do I get <w:p> w/o attributes?

11 New Member
XML:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">
  3.     <w:body>
  4.         <w:p w:rsidR="000E17AA" w:rsidRDefault="000E17AA">
  5.             <w:pPr>
  6.                 <w:tabs>
  7.                     <w:tab w:val="left" w:pos="8186"/>
  8.                 </w:tabs>
  9.                 <w:rPr>
  10.                     <w:sz w:val="14"/>
  11.                     <w:szCs w:val="14"/>
  12.                 </w:rPr>
  13.             </w:pPr>
  14.         </w:p>
  15.     </w:body>
  16. </w:document>

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"
  3.         xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
  4.         xmlns:o="urn:schemas-microsoft-com:office:office"
  5.         xmlns:v="urn:schemas-microsoft-com:vml"
  6.         xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
  7.         xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
  8.         xmlns:w10="urn:schemas-microsoft-com:office:word"
  9.         xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
  10.         xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
  11.         xmlns:rs="http://schemas.openxmlformats.org/package/2006/relationships"
  12.         version="1.0">
  13.  
  14.     <xsl:output method="html" encoding="utf-8" omit-xml-declaration="no" indent="yes"/>
  15.  
  16.  
  17.     <xsl:template match="w:p[count(ancestor::w:tbl)=0]|w:tbl[count(ancestor::w:tbl)=0]|w:footnote[count(ancestor::w:tbl)=0]|w:endnote[count(ancestor::w:tbl)=0]|w:docPart[count(ancestor::w:tbl)=0]">
  18.  
  19.         <xsl:copy>
  20.             <w:smartTag w:uri="http://schemas.openxmlformats.org/2006/smarttags" w:element="livetechdocs">
  21.                 <w:smartTagPr>
  22.                     <xsl:element name="w:attr">
  23.                         <xsl:attribute name="w:name">remap</xsl:attribute>
  24.                     </xsl:element>
  25.                 </w:smartTagPr>
  26.             </w:smartTag>
  27.  
  28.             <xsl:apply-templates/>
  29.  
  30.         </xsl:copy>
  31.  
  32.     </xsl:template>
  33.  
  34.  
  35.     <xsl:template match="node() | text()">
  36.         <xsl:copy>
  37.             <xsl:copy-of select="@*"/>
  38.             <xsl:apply-templates/>
  39.         </xsl:copy>
  40.     </xsl:template>
  41.  
  42. </xsl:stylesheet>
  43.  

Why do I get <w:p> w/o attributes? And how to fix this?


Thanks,
Nov 4 '09 #1
4 2507
Dormilich
8,658 Recognized Expert Moderator Expert
@senglory
because you don’t copy the attributes. (simply comment out the second template to see it). and the solution is thus obvious, add line 37 also to the first <copy>
Nov 4 '09 #2
senglory
11 New Member
Thanks, but LIBXSLT gives me the following error while executing XSL:

runtime error: file 0.xsl line 29 element copy-of
Attribute nodes must be added before any child nodes to an element.

Moreover, the following code produces <w:p> w/o attributes as well:
Expand|Select|Wrap|Line Numbers
  1. set xmlDocument= CreateObject("MSXML2.FreeThreadedDomDocument.3.0" )
  2. xmlDocument.async = false
  3. xmlDocument.load "I.xml"
  4.  
  5. set xsl = CreateObject("MSXML2.FreeThreadedDomDocument.3.0" )
  6. xsl.async = false
  7. xsl.load "0.xsl"
  8.  
  9.  
  10. set template = CreateObject("MSXML2.XSLTemplate")
  11. set template.stylesheet = xsl
  12. set processor = template.createProcessor
  13. processor.input = xmlDocument
  14. processor.transform()
  15.  
  16. sOutput = processor.output
  17.  
  18. msgbox sOutput
  19.  
  20. set xmlDocument3= CreateObject("MSXML2.FreeThreadedDomDocument.3.0" )
  21. xmlDocument3.loadXml sOutput
  22. xmlDocument3.save "0.xml"
How to resolve this issue?
Nov 4 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
I think it doesn’t have something to do with the C# (?) code…

where did you copy the attribute nodes in your XSL?
Nov 4 '09 #4
senglory
11 New Member
Thank you for pointing me. Fortunately, I found the right solution:

<xsl:copy>
<xsl:copy-of select="@*"/>
<w:smartTag w:uri="http://schemas.openxmlformats.org/2006/smarttags" w:element="livetechdocs">
<w:smartTagPr>


This is the right way to copy node for me
Nov 18 '09 #5

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

Similar topics

4
1370
by: Angelos | last post by:
Hello again.... I am coding php in dreamweaver. And because I like to use it for the HTML parts I want my HTML code to be unquoted and not into echo statements. BUT I ended up in something like...
1
1329
by: Jill Graham | last post by:
Hi, Here is my .aspx page : <%@ Page %> <%@ Register TagPrefix="Module" Namespace="....." assembly="....." %> <html> <head></head> <body> <table>
7
4293
by: R. Anbeeswaran | last post by:
Hi All, void main() { const int i = 20; int *p = const_cast<int*>(&i); *p = 40; cout <<"i="<< i <<"\t"<<"*p="<<*p<<"\n"; }
2
3185
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
2
10537
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
2
7344
by: Axel Dahmen | last post by:
HI, I want to dynamically add controls to a web page from within a common base class. Unfortunately, ASP.NET fails with "System.Web.HttpException: The Controls collection cannot be modified...
12
1169
by: Alan Silver | last post by:
Hello, Newbie alert, so please be patient <g> I ASP Classic, we were used to using tricks like ... <%=strName%> to insert dynamic content into an HTML block. In ASP.NET, you have various...
3
3346
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt,...
14
3117
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the...
0
7233
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
7135
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
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1570
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
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
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.