Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.01.xsd">
     <resource-config selector                 xmlns:xsl="http://www.milyn.org/xsd/smooks/xsl-1.1.xsd">

    <xsl:xsl applyOnElement="$document">
        <resource type="xsl"><xsl:template>
             <![CDATA[
            <xsl:stylesheet
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                    xmlns:xhtml="http://www.w3.org/1999/xhtml"
                    exclude-result-prefixes="smk xhtml"
                    xmlns:smk="http://milyn.codehaus.org/Smooks">

                <xsl:output method="xml" encoding="UTF-8"/>

                 <xsl:template match="/">
                    <CanonicalOrderFormat xmlns="http://canonical.codehaus.org/Order">
                        <orderId>
                            <xsl:value-of select="./smk:Order/smk:header/smk:order-id"/>
                        </orderId>
                        <item>
                            <productId>
                                <xsl:value-of select="./smk:Order/smk:order-item/smk:product-id"/>
                            </productId>
                            <title>
                                <xsl:value-of select="./smk:Order/smk:order-item/smk:title"/>
                            </title>
                            <price>
                                <xsl:value-of select="./smk:Order/smk:order-item/smk:price"/>
                            </price>
                        </item>
                    </CanonicalOrderFormat>
                </xsl:template>
            </xsl:stylesheet>
            ]]>
        </resource>xsl:template>
    </resource-config>xsl:xsl>

</smooks-resource-list>

The resource-config tells Smooks to apply the transformation that is declared "inline" in the  resource element on all <Order>. Notice that we are declaring namespace "http://milyn.codehaus.org/Smooks" with prefix "smk". This namespace is then used in the select expressions to extract the values from the Order xml instance.

...