xsl-list
[Top] [All Lists]

[xsl] Referencing content in XML and then processing in XSLT 2.0

2010-03-23 02:54:18
Good day,

If I am starting with a clean slate, and have the opportunity of
controlling both the format of the XML and the XSLT, what would be the
best way to achieve maintainable cross referencing within documents. I
need to include content on the fly from other parts of the document,
such as names, definitions, etc. One problem is that some of the cross
referenced content needs to be included into attributes, and that is
where I got my brain fried. I'm currently sitting with a hacked
together solution that is frustrating the living daylights out of me,
so I'm starting fresh!

XML content is similar to this:

<root>
  <nuttycompany name="Gone Nuts" slogan="Gone Nuts is amazing">
     <description>
       At <<this company name>> we always do our best to give you yummy nuts
     </description>
  </nuttycompany>
  <coatedcompany name="Coated Nuts" slogan="We are what
<<nuttycompany's name>> has been missing all along">
     <description>
       At <<this company name>> we say that a good nut is a sweet nut.
<<nuttycompany's name>> may say: "<<nuttycompany's slogan>>", but we
don't believe it's the truth.
     </description>
  </coatedcompany>
</root>

Output needs to be:

<root>
  <nuttycompany name="Gone Nuts" slogan="Gone nuts is amazing">
     <description>
       At Gone Nuts we always do our best to give you yummy nuts
     </description>
  </nuttycompany>
  <coatedcompany name="Coated Nuts" slogan="We are what Gone Nuts has
been missing all along">
     <description>
       At Coated Nuts we say that a good nut is a sweet nut. Gone Nuts
may say: "At Gone Nuts we always do our best to give you yummy nuts",
but we don't believe it's the truth.
     </description>
  </coatedcompany>
</root>

What would be the ideal XML source and ideal XSLT transformation to
solve this type of problem. I have considered my own placeholder
naming convention, custom XML references, XInclude,
xsl:analyze-string, two pass approach, etc, but nothing seems elegant
or correct. I'm not posting my 'solution' in fear of going down a
tangent. I'm looking for the "right" way, and not a fix for the wrong
way ;-)

Any ideas thrown this way will be dearly appreciated.

Kind regards,
Jacobus

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--