Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > XML

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-03-2009, 04:05 PM
senglory senglory is offline
Registered User
 
Join Date: Jul 2004
Posts: 13
Question Why do I get <w:p> w/o attributes?

XML:

Code:
<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">
    <w:body>
        <w:p><w:smartTag w:uri="http://schemas.openxmlformats.org/2006/smarttags" w:element="livetechdocs"><w:smartTagPr><w:attr w:name="remap"></w:attr></w:smartTagPr></w:smartTag>
            <w:pPr>
                <w:tabs>
                    <w:tab w:val="left" w:pos="8186"></w:tab>
                </w:tabs>
                <w:rPr>
                    <w:sz w:val="14"></w:sz>
                    <w:szCs w:val="14"></w:szCs>
                </w:rPr>
            </w:pPr>
        </w:p>
    </w:body>
</w:document>


XSL:

Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
        xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
        xmlns:o="urn:schemas-microsoft-com:office:office"
        xmlns:v="urn:schemas-microsoft-com:vml"
        xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
        xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
        xmlns:w10="urn:schemas-microsoft-com:office:word"
        xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
        xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
        xmlns:rs="http://schemas.openxmlformats.org/package/2006/relationships"
        version="1.0">

    <xsl:output method="html" encoding="utf-8" omit-xml-declaration="no" indent="yes"/>


    <!-- http://stackoverflow.com/questions/1312210/conditional-auto-increment-in-xsl -->
    <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]">

        <xsl:copy>
            <w:smartTag w:uri="http://schemas.openxmlformats.org/2006/smarttags" w:element="livetechdocs">
                <w:smartTagPr>
                    <xsl:element name="w:attr">
                        <xsl:attribute name="w:name">remap</xsl:attribute>
                    </xsl:element>
                </w:smartTagPr>
            </w:smartTag>

            <xsl:apply-templates/>

        </xsl:copy>

    </xsl:template>

    <!--http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XSLT/Q_23069844.html-->
    
    <xsl:template match="node() | text()">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>

Why do I get <w> w/o attributes?
Reply With Quote
  #2  
Old 11-03-2009, 07:19 PM
senglory senglory is offline
Registered User
 
Join Date: Jul 2004
Posts: 13
sorry, but the right XML is here:

Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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">
    <w:body>
        <w:p w:rsidR="000E17AA" w:rsidRDefault="000E17AA">
            <w:pPr>
                <w:tabs>
                    <w:tab w:val="left" w:pos="8186"/>
                </w:tabs>
                <w:rPr>
                    <w:sz w:val="14"/>
                    <w:szCs w:val="14"/>
                </w:rPr>
            </w:pPr>
        </w:p>
    </w:body>
</w:document>
Reply With Quote
  #3  
Old 11-17-2009, 02:49 AM
saiganesh.l saiganesh.l is offline
Registered User
 
Join Date: Nov 2009
Posts: 1
Why do I get <w:p> w/o attributes?

use <xsl:copy-of select="@*"/> for the template
match="w:p" as shown below:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:rs="http://schemas.openxmlformats.org/package/2006/relationships"
version="1.0">

<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="yes"/>


<!-- http://stackoverflow.com/questions/1...crement-in-xsl -->
<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]">

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

<xsl:apply-templates/>

</xsl:copy>

</xsl:template>

<!--http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XSLT/Q_23069844.html-->

<xsl:template match="node() | text()">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>



And the output is

<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">
<w:body>
<w:p w:rsidR="000E17AA" w:rsidRDefault="000E17AA">
<w:smartTag xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
xmlns:rs="http://schemas.openxmlformats.org/package/2006/relationships"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
w:uri="http://schemas.openxmlformats.org/2006/smarttags"
w:element="livetechdocs">
<w:smartTagPr>
<w:attr w:name="remap"/>
</w:smartTagPr>
</w:smartTag>
<w:pPr>
<w:tabs>
<w:tab w:val="left" w:pos="8186"/>
</w:tabs>
<w:rPr>
<w:sz w:val="14"/>
<w:szCs w:val="14"/>
</w:rPr>
</w:pPr>
</w:p>
</w:body>
</w:document>
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XSD - Forcing exclusive attributes Aldel XML 1 11-10-2008 11:13 AM
How to model "virtual" attributes and methods in UML Larry Hayashi Architecture and Design 2 05-01-2003 12:33 PM
XML attributes and SOAP John Rigsby XML 1 07-31-2000 01:08 PM
More XML tagNames & attributes TC XML 0 03-22-2000 08:28 PM
XML tagnames & attributes TC XML 2 03-22-2000 09:00 AM


All times are GMT -4. The time now is 08:05 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.