File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XML to XML  using XSL with output xml conforming to XSD. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML to XML  using XSL with output xml conforming to XSD." Watch "XML to XML  using XSL with output xml conforming to XSD." New topic
Author

XML to XML using XSL with output xml conforming to XSD.

Hendrik Louw
Greenhorn

Joined: Mar 01, 2007
Posts: 5
Hi All.
I need to transform XML from one structure to another structure. this output will then be sent to a external app which will proccess this xml.

This is what I have currently.


When ever I attempt to tranform this using Cooktop (An XSL Development tool)
the following error occurs
ERROR: Element content is invalid according to the DTD/Schema.
Expecting: {urn:QuoteComplete}Client.

Source: ' <xsl:call-template name="client" />'
Line: 22, Pos: 42


In java i do not get any output, i.e. blank string ("").

I am assuming that I'm doing this incorrectly, but for the life of me cannot find an example on the net to show the correct way of doing this.

Any help will be appreciated.

[ March 01, 2007: Message edited by: Hendrik Louw ]
[ March 01, 2007: Message edited by: Hendrik Louw ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I don't have much experience with Schema, but it looks to me like you declared that your XSL should be validated by a schema. (In the xsl:stylesheet element.)
Hendrik Louw
Greenhorn

Joined: Mar 01, 2007
Posts: 5
Hi, thanks for the reply.
I do realize that because I define the namespace ontop it's validating against this name space.

The problem is that I need to output this xml with the name space defenitions, but without having XSL Transformer validate against this name space.

Let me know if this isn't clear.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yes, I can see that. But I don't see why you have to put all that schema declaration business in the root element of your XSLT. If you want it in elements of your output document then do that where you generate those elements.

You would only need to declare (for example) the xmlns:qc="urn:QuoteComplete" namespace in the root of your XSLT if you were matching on elements in that namespace. And I don't think you are doing that. Not in the example you showed, anyway. And I can't think of any purpose for the xsi:schemaLocation namespace there.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: XML to XML using XSL with output xml conforming to XSD.
 
Similar Threads
XSLT parsing XML
regarding xslt
returning strings using call-template
Failing to Add HTML Tags in XSL File
Namespace problem in xslt