|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
Dynamic XML Transformation
I was wondering if you know of any way/algorithm to dynamically build an XML Stylesheet in Java to transform an XML message. The scenario is that I want to dynamically inquire on XML message(s) by certain elements. The query can be different and any number of combinations. So I would like to translate the queries into XSL and then tranform the original XML message to return the appropriate data.
For example: <company> <employee> <name>John Doe<name> <SSN>123-45-6789</SSN> </employee> <employee> <name>Jane Doe<name> <SSN>987-65-4321</SSN> </employee> <employee> <name>John Davis<name> <SSN>111-11-1111</SSN> </employee> <employee> <name>John Murphy<name> <SSN>111-22-2222</SSN> </employee> </company> Now if I I get a query for anyone named John, I would like build the apporpriate XSL to represent this and then tranform the XML above to return only the employees John (Doe, Davis, Murphy). At the same time I want the same Java code to be able to dynamically build an XSL stylesheet if a query was made for anyone named John and has a SSN that starts with 111. So then I can use this XSL to transform the XML to only return John Davis and John Murphy. I would appreciate any assistance. Thanks |
|
#2
|
|||
|
|||
|
Well, you can pass parameters to your xsl file to use during the transform, that might be easier than building a new style sheet each time. It does mean putting logic into your style sheet to determine when a value is set and when to use it, etc.
The other option would be to use a jsp (or similar java code that generates a string) as your style sheet. Then you can put your logic in the java code (if a first name was passed, include the snippet for sorting on first name, if a last name was passed, include the snippet for sorting last name), that idea.
__________________
-james |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Dynamic XML Transformation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|