[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Namespace attached to host doc rather than payload
Hello, I am working on a web service that takes an xml source from another web service and transforms it. The xml source is an xml document that contains another xml document payload: (The following examples are greatly simplified test schemas I have constructed, for easier reading.) <?xml version="1.0" ?> <data> <dataheader> <count>2</count> </dataheader> <datum datid="1"> <identifier>i1</identifier> <metadata xmlns:q="http://www.example.com/queue/"> <q:one>one</q:one> <q:two>two</q:two> </metadata> </datum> <datum datid="2"> <identifier>i2</identifier> <metadata xmlns:q="http://www.example.com/queue/"> <q:one>one</q:one> <q:two>two</q:two> </metadata> </datum> </data> This document should transformed into another type of document and its payload also transformed into another type of document: <?xml version="1.0" ?> <ListRecords> <record> <header> <identifier>i1</identifier> </header> <body> <payload xmlns:x="http://www.example.com/ex/"> <x:one>one</x:one> <x:two>two</x:two> </payload> </body> </record> <record> <header> <identifier>i2</identifier> </header> <body> <payload xmlns:x="http://www.example.com/ex/"> <x:one>one</x:one> <x:two>two</x:two> </payload> </body> </record> </ListRecords> To be conformant with the specification I am trying to meet, the namespace of the payload document must appear on the "payload" element as above. However, when I run a stylesheet transformation on the document (using .NET 1.1 System.Xml.Xsl.XslTransform) the namespace is moved to top-level "ListRecords" element. I have tried all kinds of different transformations, but none seem to have the desired effect. Reading through the FAQ I understand that namespaces are treated differently from other attributes, but I cannot see if what I am trying to achieve is possible or not with xslt. The current stylesheet I am using is: <?xml version="1.0" encoding="UTF-8"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:q="http://www.example.com/queue/" exclude-result-prefixes="q" xmlns:x="http://www.example.com/ex/"> <xsl:output method="xml" omit-xml-declaration="yes" /> <xsl:template match="data"> <ListRecords> <xsl:apply-templates select=".//datum" /> </ListRecords> </xsl:template> <xsl:template match="datum"> <record> <header> <identifier> <xsl:value-of select="identifier" /> </identifier> </header> <body> <payload xmlns:x="http://www.example.com/ex/"> <xsl:apply-templates select=".//q:one" /> <xsl:apply-templates select=".//q:two" /> </payload> </body> </record> </xsl:template> <xsl:template match="q:one"> <x:one> <xsl:value-of select="." /> </x:one> </xsl:template> <xsl:template match="q:two"> <x:two> <xsl:value-of select="." /> </x:two> </xsl:template> </xsl:transform> Any help would be most welcome. regards, David. http://mobile.yahoo.com.au - Yahoo! Mobile - Check & compose your email via SMS on your Telstra or Vodafone mobile. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|