Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Excluding Child for Repurposing with XML and XSLT

Reply
Thread Tools

Excluding Child for Repurposing with XML and XSLT

 
 
Eric Weiss
Guest
Posts: n/a
 
      07-06-2003
I have an XML document that I want to use to create two HTML versions:
one detailed and one a summary. The detailed output is straight forward
to create, but the summary output that excludes the details is giving me
trouble. The original XML file looks like:
<PROJECTS>
<PROJECT>
This is a brief description.
<DETAILS>
There are a lot of details here that should not always be in the output
html file.
</DETAILS>
There might be some more summary stuff here
</PROJECT>
</PROJECTS>

So the XSLT file to create a summary looks something like:
<HTML>
<xsl:apply-templates select="PROJECT">
</HTML>

<xsl:template match="PROJECT">
<xsl:value-of select="."/>
</xsl:template>

Is there any way to do this without adding a <SUMMARY> child to
<PROJECT>? I would prefer not to do that because I am trying to come up
with a very general approach that would allow for different amounts of
information to appear in the detail.

Thanks.

Eric

 
Reply With Quote
 
 
 
 
Eric Weiss
Guest
Posts: n/a
 
      07-06-2003
Thanks. That is just what I was looking for.

Eric


Dimitre Novatchev wrote:
> The way to exclude only a certain node is the following:
>
> 1. Use the identity rule (template) as the first in the transformation.
>
> 2. Override it with a separate rule (template) for the node that must be
> excluded.
>
> 3. To exclude the node the overriding template must be empty.
>
>
> This gives us the following transformation:
>
>
> <xsl:stylesheet version="1.0"
> xmlnssl="http://www.w3.org/1999/XSL/Transform">
>
> <xslutput omit-xml-declaration="yes"/>
>
> <xsl:template match="@* | node()">
> <xsl:copy>
> <xsl:apply-templates select="@* | node()"/>
> </xsl:copy>
> </xsl:template>
>
> <xsl:template match="DETAILS"/>
>
> </xsl:stylesheet>
>
>
> When applied on this source.xml:
>
> <PROJECTS>
> <PROJECT>
> This is a brief description.
> <DETAILS>
> There are a lot of details here that should not always be in the output
> html file.
> </DETAILS>
> There might be some more summary stuff here
> </PROJECT>
> <PROJECT>
> 2This is a brief description2.
> <DETAILS>
> 2There are a lot of details here that should not always be in the output
> html file2.
> </DETAILS>
> 2There might be some more summary stuff here2
> </PROJECT>
> </PROJECTS>
>
> The wanted result is produced:
>
> <PROJECTS>
> <PROJECT>
> This is a brief description.
>
> There might be some more summary stuff here
> </PROJECT>
> <PROJECT>
> 2This is a brief description2.
>
> 2There might be some more summary stuff here2
> </PROJECT>
> </PROJECTS>
>
>
>
>
> =====
> Cheers,
>
> Dimitre Novatchev.
> http://fxsl.sourceforge.net/ -- the home of FXSL
>
>
>
>
> "Eric Weiss" <> wrote in message
> news:...
>
>>I have an XML document that I want to use to create two HTML versions:
>>one detailed and one a summary. The detailed output is straight forward
>>to create, but the summary output that excludes the details is giving me
>>trouble. The original XML file looks like:
>><PROJECTS>
>><PROJECT>
>>This is a brief description.
>><DETAILS>
>>There are a lot of details here that should not always be in the output
>>html file.
>></DETAILS>
>>There might be some more summary stuff here
>></PROJECT>
>></PROJECTS>
>>
>>So the XSLT file to create a summary looks something like:
>><HTML>
>><xsl:apply-templates select="PROJECT">
>></HTML>
>>
>><xsl:template match="PROJECT">
>> <xsl:value-of select="."/>
>></xsl:template>
>>
>>Is there any way to do this without adding a <SUMMARY> child to
>><PROJECT>? I would prefer not to do that because I am trying to come up
>>with a very general approach that would allow for different amounts of
>>information to appear in the detail.
>>
>>Thanks.
>>
>>Eric
>>

>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem to insert an XML-element by XSLT-converting from one XML-file into another XML-file jkflens XML 2 05-30-2006 09:41 AM
Including XSLT/XML document within a XSLT document dar_imiro@hotmail.com XML 4 12-13-2005 02:26 AM
Trouble excluding select xml out to HTML using xsl kmunderwood@charter.net XML 0 03-17-2005 12:41 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57