|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XSLT question
> can i use XSLT to convert xml data to/from fixed record data? Without knowing the details of your fixed record data, it is not possible to say whether XSLT is really a good tool for the job. Generally XSLT is better for XML-to-(something XML-like), although "plain" text output in a given encoding, using characters allowed in XML documents, is pretty easy to do. Getting data into XML from fixed record data might be much easier to do with a custom application. XSLT pretty much only lets you access XML files. You could of course make a dummy file with an entity reference so that the external file will be one giant text node: <?xml version="1.0"?> <!DOCTYPE allTheData [ <!ELEMENT allTheData (#PCDATA)> <!ENTITY theFile SYSTEM "data.txt"> ]> <allTheData>&theFile;</allTheData> ...taking heed that if the encoding of data.txt is not declared with a text declaration at the top of its file, and is not otherwise evident according to the rules XML uses, then its encoding will be assumed to be UTF-8. This will affect how the data is interpreted as characters by the XML parser that is feeding information about the logical structures to the XSLT processor. You have a limitation to work around in that the data model used by XPath/XSLT does not acknowledge characters that are disallowed in XML documents. The specs do acknowledge that the DOM can be used to manually construct trees that contain wacky structures, but they don't acknowledge that you could also use the DOM to create text with characters (or character sequences) that would be illegal to have in XML documents. You might be able to get away with it, but I wouldn't rely on it. If you have an ultimate need to produce bytes that can't easily be derived from the allowed characters (and it should be noted that most XSLT processors only support a few output encodings), then you'll need to produce something "close enough" and then post-process it. -Mike
|
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
|
|||||||||

Cart








