HTML to XML transform

Discussion in 'XML' started by FrankIsHere@gmail.com, Jul 13, 2005.

  1. Guest

    I'm having some problems converting HTML to XML. Below is the source
    document.



    <html xmlns:wf="http://sometest/wf">
    <head>
    <span wf:class="cookie.equals.EntryURL" wf:values="region">
    <span class="text_red">
    <span wf:class="term.insert" wf:term="Master">United
    States</span>
    </span>
    </span>
    </head>
    </html>

    The logic is find any html tags that contain an attribute with the
    namespace "wf". Then get
    the attribute "class" and use it as a parent node with the attribute
    values as a child nodes. It's probably easier I show you what I
    want the output to look like.

    Below is the format I'm trying to convert the source to:


    <docRoot>
    <Class>
    <classname>cookie.equals.EntryURL</classname>
    <attribute aName="values">Region</attribute>
    <Class>
    <classname>term.insert</classname>
    <attribute aName="term">Master</attribute>
    <Class>
    </Class>
    </docRoot>



    This is the stylesheet I have so far:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:eek:utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>


    <xsl:template match="/ | node() | @* ">
    <xsl:copy>
    <xsl:apply-templates select="@wf:* | node()"
    xmlns:wf="http://sometest/wf"/>
    </xsl:copy>
    </xsl:template>

    <xsl:template match="@*">
    <xsl:element name="{local-name(.)}" namespace="{namespace-uri(..)}">
    <xsl:value-of select="."/>
    </xsl:element>
    </xsl:template>

    </xsl:stylesheet>


    It converts it to this:


    <?xml version="1.0" encoding="UTF-8"?>
    <html xmlns:wf="http://sometest/wf">
    <head>
    <span>
    <class>cookie.equals.EntryURL</class>
    <values>region</values>
    <span>
    <span>
    <class>term.insert</class>
    <term>Master</term>
    United States</span>
    </span>
    </span>
    </head>
    </html>
    , Jul 13, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anthony Harkness-Gripe

    Dataset to XSL Transform not displaying HTML--only XML

    Anthony Harkness-Gripe, Aug 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    987
    itnrant
    Jul 8, 2008
  2. =?Utf-8?B?UnViZW4=?=

    Transform Word XML to HTML

    =?Utf-8?B?UnViZW4=?=, Mar 27, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    4,028
    =?Utf-8?B?UnViZW4=?=
    Mar 28, 2006
  3. Johannes Koch
    Replies:
    0
    Views:
    845
    Johannes Koch
    Jul 2, 2003
  4. Marrow
    Replies:
    0
    Views:
    4,136
    Marrow
    Jul 2, 2003
  5. Marc Mendez

    XML Transform to HTML

    Marc Mendez, Sep 26, 2003, in forum: XML
    Replies:
    1
    Views:
    383
    Martin Honnen
    Sep 26, 2003
Loading...

Share This Page