Subject: [xsl] XPath 2.0 Best Practice: wrap the first node of every path expression within schema-element? From: "Costello, Roger L." <costello@xxxxxxxxx> Date: Fri, 21 Mar 2008 12:14:35 -0400 |
Hi Folks, Consider this path expression: /Book/Author/LastName Here I wrap the first node in the path expression within schema-element: /schema-element(Book)/Author/LastName The benefits of doing this are: 1. At compile-time the processor will validate the Book input element. 2. At compile-time the processor will detect errors in the path expression: 2.1 Misspelling errors: these spelling errors are caught: /schema-element(Book)/Authr/LastName (Author is misspelled) /schema-element(Book)/Author/LastNam (LastName is misspelled) 2.2 Structural errors: suppose the in-scope schema indicates that the only children of Author are FirstName and LastName; this error will be caught: /schema-element(Book)/Author/Foo (Foo is not a valid child of Author) Summary: both the input data is checked as well as the path expression itself. Are there other benefits? Are there disadvantages? Are there reasons why you would not want to do this for every path expression? /Roger
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:sort on fn:collection, Robert Koberg | Thread | Re: [xsl] XPath 2.0 Best Practice: , Martin Honnen |
Re: [xsl] Building a bidirectional , Farrukh Najmi | Date | Re: [xsl] XPath 2.0 Best Practice: , Martin Honnen |
Month |