Expand|Select|Wrap|Line Numbers
- <?xml version="1.0" encoding="UTF-8"?>
- <abc1:QWAARequest
- xmlns:abc1="http://www.mysite.com/myLink/v1/Test.xsd"
- xmlns:abc2="http://www.mysite.com/v1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.mysite.com/myLink/v1/Test.xsd Test.xsd">
- <abc1:HostID>TEST</abc1:HostID>
- <abc1:WorkForceEvent>
- <abc2:ProjectElementHasCalendarEntry>
- <abc2:relationshipType>ConfirmedSlot</abc2:relationshipType>
- <abc2:CalendarEntry xsi:type="abc2:AppointmentEvent">
- <abc2:rescheduleReason>Standard Prefix</abc2:rescheduleReason>
- </abc2:CalendarEntry>
- </abc2:ProjectElementHasCalendarEntry>
- </abc1:WorkForceEvent>
- </abc1:QWAARequest>
I am trying to build a generic xsl which can work with both xml files. Below is the same:
Expand|Select|Wrap|Line Numbers
- <?xml version="1.0" encoding="UTF-8"?>
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:prefix1="http://www.mysite.com/myLink/v1/Test.xsd"
- xmlns:prefix2="http://www.mysite.com/v1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <xsl:template match="*">
- <xsl:element name="{name()}">
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates select="node() | text()"/>
- </xsl:element>
- </xsl:template>
- <xsl:template match="text()">
- <xsl:copy-of select="."/>
- </xsl:template>
- <xsl:template match="prefix1:*">
- <xsl:element name="prefix1:{local-name()}">
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates select="node() | text()"/>
- </xsl:element>
- </xsl:template>
- <xsl:template match="prefix2:*">
- <xsl:element name="prefix2:{local-name()}">
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates select="node() | text()"/>
- </xsl:element>
- </xsl:template>
- <xsl:template match="prefix1:QWAARequest">
- <Output>
- <xsl:value-of select="prefix1:HostID"/> |
- <xsl:value-of select="prefix1:WorkForceEvent/prefix2:ProjectElementHasCalendarEntry/prefix2:relationshipType" /> |
- <xsl:value-of select="prefix1:WorkForceEvent/prefix2:ProjectElementHasCalendarEntry[prefix2:relationshipType='ConfirmedSlot']/prefix2:CalendarEntry[@xsi:type='prefix2:AppointmentEvent']/prefix2:rescheduleReason" />
- </Output>
- </xsl:template>
- </xsl:stylesheet>
Please suggest how to modify the xsl to interpret the value correctly.
I am using .Net 2.0 programming model to load the xml and xsl to generate the output.
Cheers
Rajani