Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:output method="xml" indent="yes" />
- <xsl:strip-space elements="*" />
- <!-- set ORDER to key of each element -->
- <xsl:key name="master_version" match="master_version" use="ORDER" />
- <xsl:key name="press_section" match="press_section" use="ORDER" />
- <xsl:key name="post_press_version" match="post_press_version" use="ORDER" />
- <xsl:key name="version" match="version" use="ORDER" />
- <xsl:key name="task_info_press_section" match="task_info_press_section" use="ORDER" />
- <xsl:key name="task_info_post_press" match="task_info_post_press" use="ORDER" />
- <!-- remove specified nodes -->
- <xsl:template match="ORDER" />
- <xsl:template match="ORDERPK" />
- <xsl:template match="PPVPK" />
- <xsl:template match="PRESS_x0020_SECTION" />
- <xsl:template match="POST_x0020_PRESS" />
- <!-- set attributes -->
- <xsl:template match="job_id | site_code | replace | Replace" />
- <xsl:template match="confirmed | maintenance | provisional" />
- <xsl:template match="confirmed | maintenance | provisional" />
- <!-- identity transform -->
- <xsl:template match="@*|node()">
- <xsl:copy>
- <xsl:apply-templates select="@*|node()" />
- </xsl:copy>
- </xsl:template>
- <!-- rename "dataroot" to "orders" and add attributes -->
- <xsl:template match="dataroot">
- <orders xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:tg="http://www.technique- group.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.technique-group.com/schemas TGScheduleImport_v1.4.xsd" tg:version="1.2">
- <xsl:apply-templates />
- </orders>
- </xsl:template>
- <!-- nest elements and add attributes -->
- <xsl:template match="order">
- <order job_id="{job_id}" site_code="{site_code}" replace="{Replace}">
- <xsl:apply-templates select="@*|node()" />
- <xsl:apply-templates select="key('master_version', ORDERPK)" />
- <xsl:apply-templates select="key('press_section', ORDERPK)" />
- <xsl:apply-templates select="key('post_press_version', ORDERPK)" />
- </order>
- </xsl:template>
- <xsl:template match="press_section">
- <press_section>
- <xsl:apply-templates select="node()" />
- <version>
- <xsl:apply-templates select="key('version', ORDER)/node()" />
- <xsl:apply-templates select="key('task_info_press_section', ORDER)[task_seq_id = current()/sequence_id]" />
- </version>
- </press_section>
- </xsl:template>
- <xsl:template match="post_press_version">
- <post_press_version>
- <xsl:apply-templates select="node()" />
- <xsl:apply-templates select="key('task_info_post_press', ORDER)[POST_x0020_PRESS = current()/PPVPK]" />
- </post_press_version>
- </xsl:template>
- <xsl:template match="task_info_press_section">
- <task_info confirmed="{confirmed}" maintenance="{maintenance}" provisional="{provisional}">
- <xsl:apply-templates select="node()" />
- </task_info>
- </xsl:template>
- </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement