lm1189
asked on
Breaking XML into different nodes/sections
Experts,
I have a XML and XSL I'm trying to format. Currently its combining my "Detail" nodes together, so everywhere it sees "Detail" it adds. This is fine, but I want every detail I want it to spawn a new XML collection with the related tags under it like in target.xml I attached. Any idea how I can have it break every detail section into its own collection while keeping header information in there?
Below is my XSLT:
sample.xml
whatitsdoingnow.xml
I have a XML and XSL I'm trying to format. Currently its combining my "Detail" nodes together, so everywhere it sees "Detail" it adds. This is fine, but I want every detail I want it to spawn a new XML collection with the related tags under it like in target.xml I attached. Any idea how I can have it break every detail section into its own collection while keeping header information in there?
Below is my XSLT:
<!-- Begin XST Style Sheet -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://saxon.sf.net/" >
<!-- Indent in the output -->
<xsl:output indent="yes"/>
<!-- Match the root -->
<xsl:template match="ProcessImage">
<Import> <!-- Insert our Import Node -->
<Archive ConnectionID="1" Name="1"> <!-- Define our Application Connection String -->
<Document pass="True"> <!-- Statically set documents to pass -->
<xsl:for-each select="Pages/Page"> <!-- Ignore -->
<DocFile FileLoc="{@FileName}" /> <!-- Ignore -->
</xsl:for-each>
<Fields> <!-- Grab the field data and house it under the Fields Node -->
<xsl:for-each select="DataArea/Image/Header/*[not(self::Count)]"> <!-- Ignore Count if Present -->
<Field Name="{name(.)}" value="{./text()}" pass="True"/>
</xsl:for-each>
<xsl:for-each select="DataArea/Image/Detail/*[not(self::ImageData)]"> <!-- Ignore Image Data if Present -->
<Field Name="{name(.)}" value="{./text()}" pass="True"/>
</xsl:for-each>
</Fields>
</Document>
</Archive>
</Import>
</xsl:template>
</xsl:stylesheet>
target.xmlsample.xml
whatitsdoingnow.xml
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you!
welcome
Note that it is now that breaking up the templates as I showed you before really helps keeping teh code readable
Open in new window