BizTalk Utilities CV ,   Jobs ,   Code library
 
Home Page


Add/Edit your code items
Search the code library
Browse for the code library


Schemas, xsd, xdr
simple xml notepad
Schemas using DBMS_XMLQuery Package
Tips for Designing a DTD - Part 1 of 4
Tips for Designing a DTD- Part 2 of 4 : Semi-Structured Documents
Tips for Designing a DTD- Part 3 of 4 : Database Oriented Data
Tips for Designing a DTD- Part 4 of 4 : Object Oriented Data
Getting the value of an element with optional subelements
XML Code Generator: Generating Wrapper Classes from an XML Schema
What is WDDX?
XSLT Stylesheet for summarizing the structure of an XML document
Validating XML with Schemas
Punctuated Changes In XML Documents
XMLStarlet Command Line XML Toolkit
W2XML v2.0 SR1
Free DTD for Academic Publishers
Arquemie for XML Schemas
XMLStarlet Command Line XML/XSLT Toolkit
XSD Merger


 
 

<< reBloggerSEO >>


By Robert Kviby
First Posted 08/31/2001
Times viewed 231

The Loss of Formatting When Adding a Schema


Summary Recently, when I added a schema declaration to an XML-file, I lost the formatting. I looked around for the solution to the problem and discovered that a lot developers knew about the problem but not the solution.

Recently I created an XSLT file that generated HTML from an XML-file; I didn’t have a schema for the XML-file since it was already validated. The parsing went perfect and the formatting pleased me. However, I needed a schema so I created one and added the following declaration to my top-level document, which is <chapter>:

<chapter label=10  id=ch10 xmlns:dt=x-schema:ChapterSchema.xml>


As a result of that I lost the formatting. I just couldn’t understand why. I, of course, understood that it hade something to do with the declaration of the namespace; however I couldn’t figure out exactly what was wrong. Finally I did:

The XPath expressions in an XSLT transformation are namespace aware, and to match elements from other namespaces, the namespace needs to be declared within the XSLT file. Only therefafter can you use the prefix within XPath expressions.

Hence, I added the following declaration to my stylesheet:

<xsl:stylesheet version=1.0
       xmlns:xsl=http://www.w3.org/1999/XSL/Transform xmlns:dt=x-schema:chapterschema.xml>

And voilá, the formatting is back and working perfectly! As I have understood, this error is pretty common and a lot of people don’t know what cause it; now you do!

Thanks for your time!

/Robert
Binary Bros


Rate this article on a scale of 1 to 10 (0 votes, average 0)

Your vote :  

<< reBloggerSEO >>





Leave a comment for this article
Your name
Your email (optional)
Your comment
Optional: Upload an attachment
Enter the code shown:

 
 

    Email TopXML