[oXygen-user] [Off-topic] XPATH on SGML Comments?

George Cristian Bina
Thu Nov 13 01:44:18 CST 2003


Hi Sean,

You can use comment() to refer to XML comments.
For instance if you modify the copy.xsl stylesheet from the samples/xhtml to
look like below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes" method="xml"/>
    <!-- Match document -->
    <xsl:template match="/">
        <xsl:apply-templates mode="copy" select="."/>
    </xsl:template>
    <!-- Deep copy template -->
    <xsl:template match="*|text()|@*|comment()" mode="copy">
        <xsl:copy>
            <xsl:apply-templates mode="copy" select="@*"/>
            <xsl:apply-templates mode="copy"/>
        </xsl:copy>
    </xsl:template>
    <!-- Handle default matching -->
    <xsl:template match="*"/>
</xsl:stylesheet>

then it will copy also the comment nodes in the result.

Hope that helps,
 George

----- Original Message -----
From: "Sean Wheller" <>
To: <>
Sent: Thursday, November 13, 2003 9:18 AM
Subject: [oXygen-user] [Off-topic] XPATH on SGML Comments?


> Hello,
>
> I don't see a way to perform xpath on SGML comments
> when using DTD's. In XML Schema the xsd:lang,
> xsd:appinfo and xsd:documentation can be easily
> xpathed because they are valid xml elements. But SGML
> comment tags are not true XML elements.
>
> Does anyone have a way to create an xsl that will
> extract (copy) comments from an xml file.
>
> Sean Wheller
>
>
>
> __________________________________
> Do you Yahoo!?
> Protect your identity with Yahoo! Mail AddressGuard
> http://antispam.yahoo.com/whatsnewfree
> _______________________________________________
> oXygen-user mailing list
> 
> http://www.oxygenxml.com/mailman/listinfo/oxygen-user
>



More information about the oXygen-user mailing list