<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://juniper.net/DMSchema">
	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="..\..\..\..\..\dmi-spec\junos-jsr-config.xsd">
			<security>
				<zones>
					<xsl:for-each select="a:dm/a:zone_collection/a:zone">
						<xsl:variable name="zone" select="a:name_"/>
						<security-zone>
							<name>					
								<xsl:value-of select="$zone"/>
							</name>
							<address-book>
								<xsl:apply-templates select="/a:dm/a:addrgroup_collection">
										<xsl:with-param name="zonename" select="$zone"/>
								</xsl:apply-templates>
							</address-book>
						</security-zone>
					</xsl:for-each>
				</zones>
			</security>
		</configuration>
	</xsl:template>

	<xsl:template match="/a:dm/a:addrgroup_collection">
		<xsl:param name="zonename"/>
		<xsl:for-each select="a:addrgroup[a:zone=$zonename]">
			<address-set>
					<name>
						<xsl:value-of select="a:name_"/>
					</name>
					<xsl:for-each select="a:members_collection/a:members">
						<xsl:apply-templates select="/a:dm/a:address_collection">
							<xsl:with-param name="addname" select="."/>
						</xsl:apply-templates>
					</xsl:for-each>
					<comment>
						<xsl:value-of select="a:comment"/>
					</comment>
				</address-set>
		</xsl:for-each>
	</xsl:template>

	<xsl:template match="/a:dm/a:address_collection">
		<xsl:param name="addname"/>
		<xsl:for-each select="a:address[a:name_=$addname]">
			<address>
				<name>
					<xsl:value-of select="a:name_"/>
				</name>
				<xsl:choose>
					<xsl:when test="a:address/a:subnet/a:ip">
						<ip-prefix>
							<xsl:value-of select="concat(a:address/a:subnet/a:ip,'/',a:address/a:subnet/a:netmask)"/>
						</ip-prefix>
					</xsl:when>
					<xsl:otherwise>
						<dns-name>
							<xsl:value-of select="a:address/a:domain-name"/>
						</dns-name>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:if test="a:comment">
					<comment>
						<xsl:value-of select="a:comment"/>
					</comment>
				</xsl:if>
			</address>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2007. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="map-address-set" userelativepaths="yes" externalpreview="no" url="map-address-set-in.xml" htmlbaseurl="" outputurl="map-address-set-out.xml" processortype="internal" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator="" ><advancedProp name="sInitialMode" value=""/><advancedProp name="bXsltOneIsOkay" value="true"/><advancedProp name="bSchemaAware" value="true"/><advancedProp name="bXml11" value="false"/><advancedProp name="iValidation" value="0"/><advancedProp name="bExtensions" value="true"/><advancedProp name="iWhitespace" value="0"/><advancedProp name="sInitialTemplate" value=""/><advancedProp name="bTinyTree" value="true"/><advancedProp name="bWarnings" value="true"/><advancedProp name="bUseDTD" value="false"/><advancedProp name="iErrorHandling" value="fatal"/><validatorSchema value="..\..\..\..\..\dmi-spec\junos-jsr-config.xsd"/></scenario></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="..\..\..\..\..\dmi-spec\junos-jsr-config.xsd" destSchemaRoot="configuration" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no" ><SourceSchema srcSchemaPath="..\..\..\nsm-dm.xsd" srcSchemaRoot="dm" AssociatedInstance="" loaderFunction="document" loaderFunctionUsesURI="no"/></MapperInfo><MapperBlockPosition><template match="/"><block path="configuration/security/zones/xsl:for-each" x="165" y="302"/><block path="configuration/security/zones/xsl:for-each/security-zone/name/xsl:value-of" x="329" y="244"/><block path="configuration/security/zones/xsl:for-each/security-zone/address-book/xsl:apply-templates" x="249" y="244"/></template><template match="a:address_collection"><block path="xsl:for-each" x="174" y="80"/><block path="xsl:for-each/name/xsl:value-of" x="134" y="80"/><block path="xsl:for-each/ip-prefix/xsl:value-of" x="94" y="80"/></template><template match="a:dm/a:address_collection"><block path="xsl:for-each" x="195" y="33"/><block path="xsl:for-each/ip-prefix/xsl:value-of" x="235" y="33"/></template><template match="/a:dm/a:address_collection"><block path="xsl:for-each" x="182" y="123"/><block path="xsl:for-each/address/name/xsl:value-of" x="222" y="123"/><block path="xsl:for-each/address/xsl:choose" x="102" y="123"/><block path="xsl:for-each/address/xsl:choose/xsl:when/ip-prefix/xsl:value-of" x="142" y="123"/><block path="xsl:for-each/address/xsl:choose/xsl:otherwise/dns-name/xsl:value-of" x="62" y="123"/><block path="xsl:for-each/address/xsl:if" x="205" y="26"/><block path="xsl:for-each/address/xsl:if/comment/xsl:value-of" x="165" y="26"/></template><template match="/a:dm/a:addrgroup_collection"></template></MapperBlockPosition><TemplateContext><template match="a:address_collection" mode="" srcContextPath="/dm/address_collection" srcContextFile="file:///c:/IMS/netmgt/fb-dev-dmi/gui/var/dmi-xslt/shared-objects/nsm-dm.xsd" targetContextPath="/configuration/security/zones/security-zone/address-book/address-set/address" targetContextFile="file:///c:/IMS/netmgt/fb-dev-dmi/gui/var/dmi-spec/junos-jsr-config.xsd"/><template match="/a:dm/a:address_collection" mode="" srcContextPath="/dm/address_collection" srcContextFile="file:///c:/IMS/netmgt/fb-dev-dmi/gui/var/dmi-xslt/shared-objects/nsm-dm.xsd" targetContextPath="" targetContextFile=""/></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->