Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Dynamically add XML tags to be processed?

Reply
Thread Tools

Dynamically add XML tags to be processed?

 
 
bjam
Guest
Posts: n/a
 
      04-12-2005
Hi, I am trying to create a sort of include file into my xsl files such
that calling the following template will push these xml tags into my
document such that the other xsl files can use these tags to make
decisions. In this case I want antother template that is going to
create tables be able to call this template in order to get information
for the various table paramaters and then use xsl:attribute to push
items into the table tag. Does anyone know if there is a way to
dynamically create xml tags using xsl in the document such that the
rest of the xsl style sheet processing can use these tags? Below is
the template file I am looking to create ... and further below is it's
usuage.

<!-- please note this is experimental -->
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">

<!-- import the data output template for displaying each row of resutls
-->

<!-- table settings -->
<!-- border="0" cellpadding="2" cellspacing="0" bgcolor="lightblue"
width="50%"-->
<xsl:template name="summary_table_specs">
<xml_summary_table cellpadding='2'/>
<xml_summary_table cellspacing='6'/>
<xml_summary_table border='3'/>
<xml_summary_table width='100%'/>
<xml_summary_table bgcolor='lightblue'/>
</xsl:template>


</xsl:stylesheet>

......... usage below

<xsl:import="summary_table.xsl">
<xsl:call-template name="summary_table_specs"/>
<table>
<xsl:attribute href="cellpadding">
<xsl:value-of select="/xml_summary_table[@cellpadding][text()]"/>
</xsl:attribute>

.....

 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      04-13-2005
"bjam" <(E-Mail Removed)> writes:

> Hi, I am trying to create a sort of include file into my xsl files such
> that calling the following template will push these xml tags into my
> document


It's hard to follow what you mean here. XSLT doesn't have any access to
tags in the source files, it just has access to a node tree generated by
an XML parser which has processed (and discarded) the tags.

> such that the other xsl files can use these tags to make
> decisions. In this case I want antother template that is going to
> create tables be able to call this template in order to get information
> for the various table paramaters and then use xsl:attribute to push
> items into the table tag. Does anyone know if there is a way to
> dynamically create xml tags using xsl in the document such that the
> rest of the xsl style sheet processing can use these tags? Below is
> the template file I am looking to create ... and further below is it's
> usuage.
>


> <!-- please note this is experimental -->
> <xsl:stylesheet version="1.0"
> xmlnssl="http://www.w3.org/1999/XSL/Transform">
>
> <!-- import the data output template for displaying each row of resutls
> -->
>
> <!-- table settings -->
> <!-- border="0" cellpadding="2" cellspacing="0" bgcolor="lightblue"
> width="50%"-->
> <xsl:template name="summary_table_specs">
> <xml_summary_table cellpadding='2'/>
> <xml_summary_table cellspacing='6'/>
> <xml_summary_table border='3'/>
> <xml_summary_table width='100%'/>
> <xml_summary_table bgcolor='lightblue'/>
> </xsl:template>
>
>
> </xsl:stylesheet>
>
> ........ usage below
>
> <xsl:import="summary_table.xsl">
> <xsl:call-template name="summary_table_specs"/>
> <table>
> <xsl:attribute href="cellpadding">
> <xsl:value-of select="/xml_summary_table[@cellpadding][text()]"/>
> </xsl:attribute>
>
> ....



Looking at the example then perhaps what you want to do is put the
following in to a file table.xml alongside your stylesheet
<foo>
<summary_table cellpadding='2'/>
<summary_table cellspacing='6'/>
<summary_table border='3'/>
<summary_table width='100%'/>
<summary_table bgcolor='lightblue'/>
</foo>
Note that you shouldn't (or with some parsers can not) use an element
name xml_summary_table as all names starting with xml (or XML) are
reserved.

Then you can do

<table>
<xsl:copy-of select="document('table.xml')/summary_table/@cellpadding"/>


Or depending what you want to do, perhaps you don't want this lookup
table at all and want to use an attribute set
http://www.w3.org/TR/xslt#attribute-sets

David
 
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
add document tags to xml doc DJ Stunks Perl Misc 3 09-15-2010 04:25 PM
Re: Add style to XML tags in html Andy Dingley HTML 1 09-03-2009 06:03 PM
Re: Add style to XML tags in html Nick Theodorakis HTML 0 09-03-2009 05:18 PM
Re: Add style to XML tags in html Jukka K. Korpela HTML 0 09-03-2009 04:31 PM
RegEx to find CFML tags nested in HTML tags Dean H. Saxe Perl 0 01-03-2004 06:11 PM



Advertisments