Jump to content

A puzzle for sure...


sandeman

Recommended Posts

I am wondering if you fine folks could point me in the right direction here...I am trying to make a converter between 2 applications, one is a database that creates an output to use for a roleplaying game. The other is a GUI tabletop interface with a back end of C++ and XML.The database program has the capability to export the information to html via xsl stylesheets, or an xml file.The tabletop GUI stores the character information in a central XML file that is "checked" against other xml files for validation. (Kind of like a schema I guess..)Problem is, the two apps have different namespace tags for the elements. Now, on to my question.here is an example code snippet from the database app:

<xsl:template match="character">		<font face="Courier" style="font-size:11pt">			<b>				<xsl:value-of select="name"/>				<xsl:choose>					<xsl:when test="gender != ''">						<xsl:text>, </xsl:text>						<xsl:value-of select="gender"/>						<xsl:text> </xsl:text>						<xsl:value-of select="race"/>						<xsl:text> </xsl:text>						<xsl:value-of select="classes/string"/>					</xsl:when>					<xsl:otherwise>						<xsl:value-of select="class"/>					</xsl:otherwise>				</xsl:choose>				<xsl:if test="number(number) > 1">					<xsl:text> </xsl:text>(					<xsl:value-of select="./number"/>)				</xsl:if>				<xsl:text>:</xsl:text>			</b>			<xsl:text> </xsl:text>			<xsl:if test="challenge-rating != 0">		CR 				<xsl:value-of select="challenge-rating"/>;			</xsl:if>

as you can see, what this is doing is pulling the information from an access database and creating an HTML file with the values of the information.Now, for the GUI program, the code looks like so:

<node name="charsheet">		<node name="Roscoe">			<holder name="Brad" />			<intvalue name="ac">0</intvalue>			<intvalue name="acarmorbonus">2</intvalue>			<intvalue name="acbasehelper">0</intvalue>			<intvalue name="acdexbonus">0</intvalue>			<intvalue name="acmiscbonus">0</intvalue>			<stringvalue name="acmisctitle"></stringvalue>                  ...                  </node>

Now, after looking at the XSL tutorials and scratching my head, I know that I could take the information from the original database and output it to the format that the GUI program takes. Problem that I am running into is:

<node name="charsheet">    <node>   	 <xsl:attribute name="name">      <xsl:value-of select="name"/>   	 </xsl:attribute>                                         ...

This is not seeming to work for me. What I need to do is have this:

<node name="">

with the value between the "" populated with the

<xsl:value-of select="name"/>

So, it would pull the information out of the access database and place it inbetween the "".All of the attributes for each character is not repeated, but the elements are. There are three elements:

 <stringvalue><intvalue><textvalue>

and all are attributed with name="nameofattribute"Is there any way to do this? Or am I dreaming?Thank you for your help,Sandeman

Link to comment
Share on other sites

First stop: really interesting use of XML and XSLT. Nice :) . I think the first quote in my signature actually refers to projects like this one :) .Khm... anyway... looking at the GUI program, it doesn't have a node with name "name", but it does have an attribute with that name. If all other of your XPath expressions are correct, the answer should be:

 <node name="charsheet">   <node>    <xsl:attribute name="name">     <xsl:value-of select="@name"/>    </xsl:attribute>

Notice the "@" before the name. It's an XPath selector for attributes.By the way, there's another method of using attributes, which I prefer. If you have some spare time, experiment with it:

 <node name="charsheet">   <xsl:variable name="NAME" select="@name" />   <node name="{$NAME}">

It takes less code, easier to read, and can be used multiple times over as long as it's withing the element it's used in (in our case: multiple times inside the <node name="charset"> element.

Link to comment
Share on other sites

First stop: really interesting use of XML and XSLT. Nice biggrin.gif . I think the first quote in my signature actually refers to projects like this one laugh.gif .Khm... anyway... looking at the GUI program, it doesn't have a node with name "name", but it does have an attribute with that name. If all other of your XPath expressions are correct, the answer should be:CODE<node name="charsheet">  <node>  <xsl:attribute name="name">    <xsl:value-of select="@name"/>  </xsl:attribute>Notice the "@" before the name. It's an XPath selector for attributes.By the way, there's another method of using attributes, which I prefer. If you have some spare time, experiment with it:CODE<node name="charsheet">  <xsl:variable name="NAME" select="@name" />  <node name="{$NAME}">It takes less code, easier to read, and can be used multiple times over as long as it's withing the element it's used in (in our case: multiple times inside the <node name="charset"> element.
Okay, if I can be real dense for a moment.The xsl stylesheet is applied to the xml that is generated from the export of the database. (In this case, an access database.) The data is then displayed in a format that is readable, right?What I want to do is create the exporting xml in html format so I can cut and paste it into the xml file for the GUI program.Is it more efficient to create all the variables like you did first, then put them into the code? Does this have to be in order of all the nodes? Or can I do it first, then fill in the blanks? I guess it would look start like like so:
			<xsl:attribute name="ac" >			<xsl:attribute name="acarmorbonus">			<xsl:attribute name="acbasehelper">			<xsl:attribute name="acdexbonus">			<xsl:attribute name="acmiscbonus">			<xsl:attribute name="acmisctitle">			<xsl:attribute name="acshieldbonus">			<xsl:attribute name="acsizebonus">			<xsl:attribute name="acsurprised">			<xsl:attribute name="age">			<xsl:attribute name="alignment">			<xsl:attribute name="appearance">			<xsl:attribute name="appraisemisc">			<xsl:attribute name="appraiseranks">			<xsl:attribute name="appraisestat">			<xsl:attribute name="appraisestate">			<xsl:attribute name="appraisetotal">			<xsl:attribute name="armorcheckpenalty">			<xsl:attribute name="armorcheckpenaltydbl">			<xsl:attribute name="arrows1">			<xsl:attribute name="arrows10">			<xsl:attribute name="arrows11">			<xsl:attribute name="arrows12">			<xsl:attribute name="arrows13">			<xsl:attribute name="arrows14">			<xsl:attribute name="arrows15">			<xsl:attribute name="arrows16">			<xsl:attribute name="arrows17">			<xsl:attribute name="arrows18">			<xsl:attribute name="arrows19">			<xsl:attribute name="arrows2">			<xsl:attribute name="arrows20">			<xsl:attribute name="arrows3">			<xsl:attribute name="arrows4">			<xsl:attribute name="arrows5">			<xsl:attribute name="arrows6">			<xsl:attribute name="arrows7">			<xsl:attribute name="arrows8">			<xsl:attribute name="arrows9">			<xsl:attribute name="balancemisc">			<xsl:attribute name="balanceranks">			<xsl:attribute name="balancestat">			<xsl:attribute name="balancestate">			<xsl:attribute name="balancetotal">			<xsl:attribute name="baseattackbonus">			<xsl:attribute name="blankskill1keyability">			<xsl:attribute name="blankskill1misc">			<xsl:attribute name="blankskill1ranks">			<xsl:attribute name="blankskill1stat">			<xsl:attribute name="blankskill1state">			<xsl:attribute name="blankskill1text">			<xsl:attribute name="blankskill1total">			<xsl:attribute name="blankskill2keyability">			<xsl:attribute name="blankskill2misc">			<xsl:attribute name="blankskill2ranks">			<xsl:attribute name="blankskill2stat">			<xsl:attribute name="blankskill2state">			<xsl:attribute name="blankskill2text">			<xsl:attribute name="blankskill2total">			<xsl:attribute name="blankskill3keyability">			<xsl:attribute name="blankskill3misc">			<xsl:attribute name="blankskill3ranks">			<xsl:attribute name="blankskill3stat">			<xsl:attribute name="blankskill3state">			<xsl:attribute name="blankskill3text">			<xsl:attribute name="blankskill3total">			<xsl:attribute name="blankskill4keyability">			<xsl:attribute name="blankskill4misc">			<xsl:attribute name="blankskill4ranks">			<xsl:attribute name="blankskill4stat">			<xsl:attribute name="blankskill4state">			<xsl:attribute name="blankskill4text">			<xsl:attribute name="blankskill4total">			<xsl:attribute name="blankskill5keyability">			<xsl:attribute name="blankskill5misc">			<xsl:attribute name="blankskill5ranks">			<xsl:attribute name="blankskill5stat">			<xsl:attribute name="blankskill5state">			<xsl:attribute name="blankskill5text">			<xsl:attribute name="blankskill5total">			<xsl:attribute name="blankskill6keyability">			<xsl:attribute name="blankskill6misc">			<xsl:attribute name="blankskill6ranks">			<xsl:attribute name="blankskill6stat">			<xsl:attribute name="blankskill6state">			<xsl:attribute name="blankskill6text">			<xsl:attribute name="blankskill6total">			<xsl:attribute name="blankskill7keyability">			<xsl:attribute name="blankskill7misc">			<xsl:attribute name="blankskill7ranks">			<xsl:attribute name="blankskill7stat">			<xsl:attribute name="blankskill7state">			<xsl:attribute name="blankskill7text">			<xsl:attribute name="blankskill7total">			<xsl:attribute name="blankskill8keyability">			<xsl:attribute name="blankskill8misc">			<xsl:attribute name="blankskill8ranks">			<xsl:attribute name="blankskill8stat">			<xsl:attribute name="blankskill8state">			<xsl:attribute name="blankskill8text">			<xsl:attribute name="blankskill8total">			<xsl:attribute name="bluffmisc">			<xsl:attribute name="bluffranks">			<xsl:attribute name="bluffstat">			<xsl:attribute name="bluffstate">			<xsl:attribute name="blufftotal">			<xsl:attribute name="bolts1">			<xsl:attribute name="bolts10">			<xsl:attribute name="bolts11">			<xsl:attribute name="bolts12">			<xsl:attribute name="bolts13">			<xsl:attribute name="bolts14">			<xsl:attribute name="bolts15">			<xsl:attribute name="bolts16">			<xsl:attribute name="bolts17">			<xsl:attribute name="bolts18">			<xsl:attribute name="bolts19">			<xsl:attribute name="bolts2">			<xsl:attribute name="bolts20">			<xsl:attribute name="bolts3">			<xsl:attribute name="bolts4">			<xsl:attribute name="bolts5">			<xsl:attribute name="bolts6">			<xsl:attribute name="bolts7">			<xsl:attribute name="bolts8">			<xsl:attribute name="bolts9">			<xsl:attribute name="camouflagemisc">			<xsl:attribute name="camouflageranks">			<xsl:attribute name="camouflagestat">			<xsl:attribute name="camouflagestate">			<xsl:attribute name="camouflagetotal">			<xsl:attribute name="charisma">			<xsl:attribute name="charismabonus">			<xsl:attribute name="charismadamage">			<xsl:attribute name="charismatotal">			<xsl:attribute name="class1">			<xsl:attribute name="class2">			<xsl:attribute name="class3">			<xsl:attribute name="climbmisc">			<xsl:attribute name="climbranks">			<xsl:attribute name="climbstat">			<xsl:attribute name="climbstate">			<xsl:attribute name="climbtotal">			<xsl:attribute name="clothing">			<xsl:attribute name="coinamount1">			<xsl:attribute name="coinamount2">			<xsl:attribute name="coinamount3">			<xsl:attribute name="coinamount4">			<xsl:attribute name="coinamount5">			<xsl:attribute name="coinamount6">			<xsl:attribute name="coinname1">			<xsl:attribute name="coinname2">			<xsl:attribute name="coinname3">			<xsl:attribute name="coinname4">			<xsl:attribute name="coinname5">			<xsl:attribute name="coinname6">			<xsl:attribute name="coinother">			<xsl:attribute name="concealmentac1">			<xsl:attribute name="concealmentac2">			<xsl:attribute name="concealmentac3">			<xsl:attribute name="concealmentac4">			<xsl:attribute name="concealmenthelper">			<xsl:attribute name="concealmentreflex1">			<xsl:attribute name="concealmentreflex2">			<xsl:attribute name="concealmentreflex3">			<xsl:attribute name="concealmentreflex4">			<xsl:attribute name="concentrationmisc">			<xsl:attribute name="concentrationranks">			<xsl:attribute name="concentrationstat">			<xsl:attribute name="concentrationstate">			<xsl:attribute name="concentrationtotal">			<xsl:attribute name="constitution">13>			<xsl:attribute name="constitutionbonus">			<xsl:attribute name="constitutiondamage">			<xsl:attribute name="constitutiontotal">			<xsl:attribute name="craft1misc">			<xsl:attribute name="craft1ranks">			<xsl:attribute name="craft1stat">			<xsl:attribute name="craft1state">			<xsl:attribute name="craft1text">			<xsl:attribute name="craft1total">			<xsl:attribute name="craft2misc">			<xsl:attribute name="craft2ranks">			<xsl:attribute name="craft2stat">			<xsl:attribute name="craft2state">			<xsl:attribute name="craft2text">			<xsl:attribute name="craft2total">			<xsl:attribute name="craft3misc">			<xsl:attribute name="craft3ranks">			<xsl:attribute name="craft3stat">			<xsl:attribute name="craft3state">			<xsl:attribute name="craft3text">			<xsl:attribute name="craft3total">			<xsl:attribute name="craftmisc1">			<xsl:attribute name="craftmisc2">			<xsl:attribute name="craftname1">			<xsl:attribute name="craftname2">			<xsl:attribute name="craftranks1">			<xsl:attribute name="craftranks2">			<xsl:attribute name="craftstat">			<xsl:attribute name="craftstate">			<xsl:attribute name="crafttotal1">			<xsl:attribute name="crafttotal2">			<xsl:attribute name="decipherscriptmisc">			<xsl:attribute name="decipherscriptranks">			<xsl:attribute name="decipherscriptstat">			<xsl:attribute name="decipherscriptstate">			<xsl:attribute name="decipherscripttotal">			<xsl:attribute name="dexterity">			<xsl:attribute name="dexteritybonus">			<xsl:attribute name="dexteritydamage">			<xsl:attribute name="dexteritytotal">			<xsl:attribute name="diplomacymisc">			<xsl:attribute name="diplomacyranks">			<xsl:attribute name="diplomacystat">			<xsl:attribute name="diplomacystate">			<xsl:attribute name="diplomacytotal">			<xsl:attribute name="disabledevicemisc">			<xsl:attribute name="disabledeviceranks">			<xsl:attribute name="disabledevicestat">			<xsl:attribute name="disabledevicestate">			<xsl:attribute name="disabledevicetotal">			<xsl:attribute name="disguisemisc">			<xsl:attribute name="disguiseranks">			<xsl:attribute name="disguisestat">			<xsl:attribute name="disguisestate">			<xsl:attribute name="disguisetotal">			<xsl:attribute name="encumbranceheavyload">			<xsl:attribute name="encumbranceliftoffground">			<xsl:attribute name="encumbranceliftoverhead">			<xsl:attribute name="encumbrancelightload">			<xsl:attribute name="encumbranceload">			<xsl:attribute name="encumbrancemediumload">			<xsl:attribute name="encumbrancepushordrag">			<xsl:attribute name="equippedinventory">			<xsl:attribute name="escapeartistmisc">			<xsl:attribute name="escapeartistranks">			<xsl:attribute name="escapeartiststat">			<xsl:attribute name="escapeartiststate">			<xsl:attribute name="escapeartisttotal">			<xsl:attribute name="exp">			<xsl:attribute name="expneeded">			<xsl:attribute name="feats">			<xsl:attribute name="forgerymisc">			<xsl:attribute name="forgeryranks">			<xsl:attribute name="forgerystat">			<xsl:attribute name="forgerystate">			<xsl:attribute name="forgerytotal">			<xsl:attribute name="fortitudesave">			<xsl:attribute name="fortitudesavebase">			<xsl:attribute name="fortitudesavemisc">			<xsl:attribute name="fortitudesavestatbonus">			<xsl:attribute name="gatherinformationmisc">			<xsl:attribute name="gatherinformationranks">			<xsl:attribute name="gatherinformationstat">			<xsl:attribute name="gatherinformationstate">			<xsl:attribute name="gatherinformationtotal">			<xsl:attribute name="gender">			<xsl:attribute name="handleanimalmisc">			<xsl:attribute name="handleanimalranks">			<xsl:attribute name="handleanimalstat">			<xsl:attribute name="handleanimalstate">			<xsl:attribute name="handleanimaltotal">			<xsl:attribute name="healerskit1">			<xsl:attribute name="healerskit10">			<xsl:attribute name="healerskit11">			<xsl:attribute name="healerskit12">			<xsl:attribute name="healerskit13">			<xsl:attribute name="healerskit14">			<xsl:attribute name="healerskit15">			<xsl:attribute name="healerskit16">			<xsl:attribute name="healerskit17">			<xsl:attribute name="healerskit18">			<xsl:attribute name="healerskit19">			<xsl:attribute name="healerskit2">			<xsl:attribute name="healerskit20">			<xsl:attribute name="healerskit3">			<xsl:attribute name="healerskit4">			<xsl:attribute name="healerskit5">			<xsl:attribute name="healerskit6">			<xsl:attribute name="healerskit7">			<xsl:attribute name="healerskit8">			<xsl:attribute name="healerskit9">			<xsl:attribute name="healmisc">			<xsl:attribute name="healranks">			<xsl:attribute name="healstat">			<xsl:attribute name="healstate">			<xsl:attribute name="healtotal">			<xsl:attribute name="height">			<xsl:attribute name="hidemisc">			<xsl:attribute name="hideranks">			<xsl:attribute name="hidestat">			<xsl:attribute name="hidestate">			<xsl:attribute name="hidetotal">			<xsl:attribute name="hp">27>			<xsl:attribute name="initiative">			<xsl:attribute name="initiativedexbonus">			<xsl:attribute name="initiativemiscbonus">			<xsl:attribute name="intelligence">			<xsl:attribute name="intelligencebonus">			<xsl:attribute name="intelligencedamage">			<xsl:attribute name="intelligencetotal">			<xsl:attribute name="intimidatemisc">			<xsl:attribute name="intimidateranks">			<xsl:attribute name="intimidatestat">			<xsl:attribute name="intimidatestate">			<xsl:attribute name="intimidatetotal">			<xsl:attribute name="inventory">			<xsl:attribute name="itemdescription">			<xsl:attribute name="jumpmisc">			<xsl:attribute name="jumpranks">			<xsl:attribute name="jumpstat">			<xsl:attribute name="jumpstate">			<xsl:attribute name="jumptotal">			<xsl:attribute name="knowledgearcanamisc">			<xsl:attribute name="knowledgearcanaranks">			<xsl:attribute name="knowledgearcanastat">			<xsl:attribute name="knowledgearcanastate">			<xsl:attribute name="knowledgearcanatotal">			<xsl:attribute name="knowledgedungeoneeringmisc">			<xsl:attribute name="knowledgedungeoneeringranks">			<xsl:attribute name="knowledgedungeoneeringstat">			<xsl:attribute name="knowledgedungeoneeringstate">			<xsl:attribute name="knowledgedungeoneeringtotal">			<xsl:attribute name="knowledgeengineeringmisc">			<xsl:attribute name="knowledgeengineeringranks">			<xsl:attribute name="knowledgeengineeringstat">			<xsl:attribute name="knowledgeengineeringstate">			<xsl:attribute name="knowledgeengineeringtotal">			<xsl:attribute name="knowledgegeographymisc">			<xsl:attribute name="knowledgegeographyranks">			<xsl:attribute name="knowledgegeographystat">			<xsl:attribute name="knowledgegeographystate">			<xsl:attribute name="knowledgegeographytotal">			<xsl:attribute name="knowledgehistorymisc">			<xsl:attribute name="knowledgehistoryranks">			<xsl:attribute name="knowledgehistorystat">			<xsl:attribute name="knowledgehistorystate">			<xsl:attribute name="knowledgehistorytotal">			<xsl:attribute name="knowledgelocalmisc">			<xsl:attribute name="knowledgelocalranks">			<xsl:attribute name="knowledgelocalstat">			<xsl:attribute name="knowledgelocalstate">			<xsl:attribute name="knowledgelocaltotal">			<xsl:attribute name="knowledgenaturemisc">			<xsl:attribute name="knowledgenatureranks">			<xsl:attribute name="knowledgenaturestat">			<xsl:attribute name="knowledgenaturestate">			<xsl:attribute name="knowledgenaturetotal">			<xsl:attribute name="knowledgenobilitymisc">			<xsl:attribute name="knowledgenobilityranks">			<xsl:attribute name="knowledgenobilitystat">			<xsl:attribute name="knowledgenobilitystate">			<xsl:attribute name="knowledgenobilitytotal">			<xsl:attribute name="knowledgereligionmisc">			<xsl:attribute name="knowledgereligionranks">			<xsl:attribute name="knowledgereligionstat">			<xsl:attribute name="knowledgereligionstate">			<xsl:attribute name="knowledgereligiontotal">			<xsl:attribute name="knowledgetheplanesmisc">			<xsl:attribute name="knowledgetheplanesranks">			<xsl:attribute name="knowledgetheplanesstat">			<xsl:attribute name="knowledgetheplanesstate">			<xsl:attribute name="knowledgetheplanestotal">			<xsl:attribute name="languages">			<xsl:attribute name="level1">			<xsl:attribute name="level2">			<xsl:attribute name="level3">			<xsl:attribute name="listenmisc">			<xsl:attribute name="listenranks">			<xsl:attribute name="listenstat">			<xsl:attribute name="listenstate">			<xsl:attribute name="listentotal">			<xsl:attribute name="location1label">			<xsl:attribute name="location1text">			<xsl:attribute name="location2label">			<xsl:attribute name="location2text">			<xsl:attribute name="location3label">			<xsl:attribute name="location3text">			<xsl:attribute name="location4label">			<xsl:attribute name="location4text">			<xsl:attribute name="meleeattackbasemod">			<xsl:attribute name="meleeattackbonus">			<xsl:attribute name="meleeattackstrmod">			<xsl:attribute name="misc1">			<xsl:attribute name="misc10">			<xsl:attribute name="misc11">			<xsl:attribute name="misc12">			<xsl:attribute name="misc13">			<xsl:attribute name="misc14">			<xsl:attribute name="misc15">			<xsl:attribute name="misc16">			<xsl:attribute name="misc17">			<xsl:attribute name="misc18">			<xsl:attribute name="misc19">			<xsl:attribute name="misc2">			<xsl:attribute name="misc20">			<xsl:attribute name="misc3">			<xsl:attribute name="misc4">			<xsl:attribute name="misc5">			<xsl:attribute name="misc6">			<xsl:attribute name="misc7">			<xsl:attribute name="misc8">			<xsl:attribute name="misc9">			<xsl:attribute name="motivationmisc">			<xsl:attribute name="motivationranks">			<xsl:attribute name="motivationstat">			<xsl:attribute name="motivationstate">			<xsl:attribute name="motivationtotal">			<xsl:attribute name="movesilentlymisc">			<xsl:attribute name="movesilentlyranks">			<xsl:attribute name="movesilentlystat">			<xsl:attribute name="movesilentlystate">			<xsl:attribute name="movesilentlytotal">			<xsl:attribute name="name">			<xsl:attribute name="notes1">			<xsl:attribute name="notes2">			<xsl:attribute name="openlockmisc">			<xsl:attribute name="openlockranks">			<xsl:attribute name="openlockstat">			<xsl:attribute name="openlockstate">			<xsl:attribute name="openlocktotal">			<xsl:attribute name="otherresists">			<xsl:attribute name="performmisc1">			<xsl:attribute name="performmisc2">			<xsl:attribute name="performname1">			<xsl:attribute name="performname2">			<xsl:attribute name="performranks1">			<xsl:attribute name="performranks2">			<xsl:attribute name="performstat">			<xsl:attribute name="performstate">			<xsl:attribute name="performtotal1">			<xsl:attribute name="performtotal2">			<xsl:attribute name="professionmisc1">			<xsl:attribute name="professionmisc2">			<xsl:attribute name="professionname1">			<xsl:attribute name="professionname2">			<xsl:attribute name="professionranks1">			<xsl:attribute name="professionranks2">			<xsl:attribute name="professionstat">			<xsl:attribute name="professionstate">			<xsl:attribute name="professiontotal1">			<xsl:attribute name="professiontotal2">			<xsl:attribute name="progression">			<xsl:attribute name="race">Halfling>			<xsl:attribute name="rangeattackbasemod">			<xsl:attribute name="rangeattackbonus">			<xsl:attribute name="rangeattackdexmod">			<xsl:attribute name="rations1">			<xsl:attribute name="rations10">			<xsl:attribute name="rations11">			<xsl:attribute name="rations12">			<xsl:attribute name="rations13">			<xsl:attribute name="rations14">			<xsl:attribute name="rations2">			<xsl:attribute name="rations3">			<xsl:attribute name="rations4">			<xsl:attribute name="rations5">			<xsl:attribute name="rations6">			<xsl:attribute name="rations7">			<xsl:attribute name="rations8">			<xsl:attribute name="rations9">			<xsl:attribute name="readlipsmisc">			<xsl:attribute name="readlipsranks">			<xsl:attribute name="readlipsstat">			<xsl:attribute name="readlipsstate">			<xsl:attribute name="readlipstotal">			<xsl:attribute name="reflexsave">			<xsl:attribute name="reflexsavebase">			<xsl:attribute name="reflexsavemisc">			<xsl:attribute name="reflexsavestatbonus">			<xsl:attribute name="ridemisc">			<xsl:attribute name="rideranks">			<xsl:attribute name="ridestat">			<xsl:attribute name="ridestate">			<xsl:attribute name="ridetotal">			<xsl:attribute name="run">			<xsl:attribute name="searchmisc">			<xsl:attribute name="searchranks">			<xsl:attribute name="searchstat">			<xsl:attribute name="searchstate">			<xsl:attribute name="searchtotal">			<xsl:attribute name="sensemotivemisc">			<xsl:attribute name="sensemotiveranks">			<xsl:attribute name="sensemotivestat">			<xsl:attribute name="sensemotivestate">			<xsl:attribute name="sensemotivetotal">			<xsl:attribute name="size">			<xsl:attribute name="sleightofhandmisc">			<xsl:attribute name="sleightofhandranks">			<xsl:attribute name="sleightofhandstat">			<xsl:attribute name="sleightofhandstate">			<xsl:attribute name="sleightofhandtotal">			<xsl:attribute name="speaklanguage1misc">			<xsl:attribute name="speaklanguage1ranks">			<xsl:attribute name="speaklanguage1stat">			<xsl:attribute name="speaklanguage1state">			<xsl:attribute name="speaklanguage1text">			<xsl:attribute name="speaklanguage1total">			<xsl:attribute name="speaklanguage2misc">			<xsl:attribute name="speaklanguage2ranks">			<xsl:attribute name="speaklanguage2stat">			<xsl:attribute name="speaklanguage2state">			<xsl:attribute name="speaklanguage2text">			<xsl:attribute name="speaklanguage2total">			<xsl:attribute name="speaklanguage3misc">			<xsl:attribute name="speaklanguage3ranks">			<xsl:attribute name="speaklanguage3stat">			<xsl:attribute name="speaklanguage3state">			<xsl:attribute name="speaklanguage3text">			<xsl:attribute name="speaklanguage3total">			<xsl:attribute name="speaklanguage4misc">			<xsl:attribute name="speaklanguage4ranks">			<xsl:attribute name="speaklanguage4stat">			<xsl:attribute name="speaklanguage4state">			<xsl:attribute name="speaklanguage4text">			<xsl:attribute name="speaklanguage4total">			<xsl:attribute name="speaklanguage5misc">			<xsl:attribute name="speaklanguage5ranks">			<xsl:attribute name="speaklanguage5stat">			<xsl:attribute name="speaklanguage5state">			<xsl:attribute name="speaklanguage5text">			<xsl:attribute name="speaklanguage5total">			<xsl:attribute name="speaklanguageranks">			<xsl:attribute name="speaklanguagestate">			<xsl:attribute name="speaklanguagetotal">			<xsl:attribute name="specialabilities">			<xsl:attribute name="speed">			<node name="spell">				<holder name="" />			</node>			<xsl:attribute name="spellcraftmisc">			<xsl:attribute name="spellcraftranks">			<xsl:attribute name="spellcraftstat">			<xsl:attribute name="spellcraftstate">			<xsl:attribute name="spellcrafttotal">			<xsl:attribute name="spelldclevel0">			<xsl:attribute name="spelldclevel1">			<xsl:attribute name="spelldclevel2">			<xsl:attribute name="spelldclevel3">			<xsl:attribute name="spelldclevel4">			<xsl:attribute name="spelldclevel5">			<xsl:attribute name="spelldclevel6">			<xsl:attribute name="spelldclevel7">			<xsl:attribute name="spelldclevel8">			<xsl:attribute name="spelldclevel9">			<xsl:attribute name="spellmisclabel">			<xsl:attribute name="spellmisclevel0">			<xsl:attribute name="spellmisclevel1">			<xsl:attribute name="spellmisclevel2">			<xsl:attribute name="spellmisclevel3">			<xsl:attribute name="spellmisclevel4">			<xsl:attribute name="spellmisclevel5">			<xsl:attribute name="spellmisclevel6">			<xsl:attribute name="spellmisclevel7">			<xsl:attribute name="spellmisclevel8">			<xsl:attribute name="spellmisclevel9">			<xsl:attribute name="spellsperdaylevel0">			<xsl:attribute name="spellsperdaylevel1">			<xsl:attribute name="spellsperdaylevel2">			<xsl:attribute name="spellsperdaylevel3">			<xsl:attribute name="spellsperdaylevel4">			<xsl:attribute name="spellsperdaylevel5">			<xsl:attribute name="spellsperdaylevel6">			<xsl:attribute name="spellsperdaylevel7">			<xsl:attribute name="spellsperdaylevel8">			<xsl:attribute name="spellsperdaylevel9">			<xsl:attribute name="spotmisc">			<xsl:attribute name="spotranks">			<xsl:attribute name="spotstat">			<xsl:attribute name="spotstate">			<xsl:attribute name="spottotal">			<xsl:attribute name="strength">			<xsl:attribute name="strengthbonus">			<xsl:attribute name="strengthdamage">			<xsl:attribute name="strengthtotal">			<xsl:attribute name="subdual">			<xsl:attribute name="surehandedmisc">			<xsl:attribute name="surehandedranks">			<xsl:attribute name="surehandedstat">			<xsl:attribute name="surehandedstate">			<xsl:attribute name="surehandedtotal">			<xsl:attribute name="survivalmisc">			<xsl:attribute name="survivalranks">			<xsl:attribute name="survivalstat">			<xsl:attribute name="survivalstate">			<xsl:attribute name="survivaltotal">			<xsl:attribute name="swimmisc">			<xsl:attribute name="swimranks">			<xsl:attribute name="swimstat">			<xsl:attribute name="swimstate">			<xsl:attribute name="swimtotal">			<xsl:attribute name="treasure1label">			<xsl:attribute name="treasure1text">			<xsl:attribute name="treasure2label">			<xsl:attribute name="treasure2text">			<xsl:attribute name="treasure3label">			<xsl:attribute name="treasure3text">			<xsl:attribute name="treasure4label">			<xsl:attribute name="treasure4text">			<xsl:attribute name="treasuremisc">			<xsl:attribute name="tumblemisc">			<xsl:attribute name="tumbleranks">			<xsl:attribute name="tumblestat">			<xsl:attribute name="tumblestate">			<xsl:attribute name="tumbletotal">			<xsl:attribute name="usemagicdevicemisc">			<xsl:attribute name="usemagicdeviceranks">			<xsl:attribute name="usemagicdevicestat">			<xsl:attribute name="usemagicdevicestate">			<xsl:attribute name="usemagicdevicetotal">			<xsl:attribute name="useropemisc">			<xsl:attribute name="useroperanks">			<xsl:attribute name="useropestat">			<xsl:attribute name="useropestate">			<xsl:attribute name="useropetotal">			<xsl:attribute name="weapon1">			<xsl:attribute name="weapon1attackbonus">			<xsl:attribute name="weapon1attackbonus2">			<xsl:attribute name="weapon1attackbonus3">			<xsl:attribute name="weapon1attackbonus4">			<xsl:attribute name="weapon1critical">			<xsl:attribute name="weapon1damage">			<xsl:attribute name="weapon2">dagger>			<xsl:attribute name="weapon2attackbonus">			<xsl:attribute name="weapon2attackbonus2">			<xsl:attribute name="weapon2attackbonus3">			<xsl:attribute name="weapon2attackbonus4">			<xsl:attribute name="weapon2critical">			<xsl:attribute name="weapon2damage">			<xsl:attribute name="weapon3">			<xsl:attribute name="weapon3attackbonus">			<xsl:attribute name="weapon3attackbonus2">			<xsl:attribute name="weapon3attackbonus3">			<xsl:attribute name="weapon3attackbonus4">			<xsl:attribute name="weapon3critical">			<xsl:attribute name="weapon3damage">			<xsl:attribute name="weapon4">			<xsl:attribute name="weapon4attackbonus">			<xsl:attribute name="weapon4attackbonus2">			<xsl:attribute name="weapon4attackbonus3">			<xsl:attribute name="weapon4attackbonus4">			<xsl:attribute name="weapon4critical">			<xsl:attribute name="weapon4damage">			<xsl:attribute name="weapon5">			<xsl:attribute name="weapon5attackbonus">			<xsl:attribute name="weapon5attackbonus2">			<xsl:attribute name="weapon5attackbonus3">			<xsl:attribute name="weapon5attackbonus4">			<xsl:attribute name="weapon5critical">			<xsl:attribute name="weapon5damage">			<xsl:attribute name="weight">			<xsl:attribute name="willsave">			<xsl:attribute name="willsavebase">			<xsl:attribute name="willsavemisc">			<xsl:attribute name="willsavestatbonus">			<xsl:attribute name="wisdom">			<xsl:attribute name="wisdombonus">			<xsl:attribute name="wisdomdamage">			<xsl:attribute name="wisdomtotal">			<xsl:attribute name="wounds">		

For each, I could add select="@nameindatabase?Then after all the variables are made, then I could put them into the corresponding nodes?for example:

<stringvalue name="wounds">{$wounds}</stringvalue>

Am I on the right track here? This would make things soooooo much easier! :)Sandeman

Link to comment
Share on other sites

LOL. An XSLT database (practically). Bad idea... nevermind...In truth, XSLT only visualises what you want, but it doesn't actually give the disired output. You need some server side scripting language or a custom made C++ application that would generate the REAL source code when the file is accesed. I mean that for example:

<p>  <xsl:variable name="link" select="link" />  <a href="{$link}>some text</a></p>

Is displayed as if it was:

<p><a href="whatever the value of 'link' is">some text</a></p>

but when browsers and other languages refer to the XML or XSLT, they read their respective codes, not the output. In order for the browser or application to read the output, the output must fisrt be generated with some kind of parser.A note to keep in mind of using multiple variables is that they must be used in the order they are declared.

<xsl:variable name="link" select="link" /><xsl:variable name="value" select="value" />

This will give you an error if you use value before link, but it won't give an error if link is used at least once before value.So yes, I personally think it's better to declare all the variables at the top, as long as you know their order.As for how to get a value of a variable in a node. No. It's not like you did it. It's more simple :) :

<stringvalue name="wounds"><xsl:value-of select="$wounds" /></stringvalue>

Link to comment
Share on other sites

LOL. An XSLT database (practically). Bad idea... nevermind...In truth, XSLT only visualises what you want, but it doesn't actually give the disired output. You need some server side scripting language or a custom made C++ application that would generate the REAL source code when the file is accesed. I mean that for example:
<p>  <xsl:variable name="link" select="link" />  <a href="{$link}>some text</a></p>

Is displayed as if it was:

<p><a href="whatever the value of 'link' is">some text</a></p>

but when browsers and other languages refer to the XML or XSLT, they read their respective codes, not the output. In order for the browser or application to read the output, the output must fisrt be generated with some kind of parser.A note to keep in mind of using multiple variables is that they must be used in the order they are declared.

<xsl:variable name="link" select="link" /><xsl:variable name="value" select="value" />

This will give you an error if you use value before link, but it won't give an error if link is used at least once before value.So yes, I personally think it's better to declare all the variables at the top, as long as you know their order.As for how to get a value of a variable in a node. No. It's not like you did it. It's more simple :) :

<stringvalue name="wounds"><xsl:value-of select="$wounds" /></stringvalue>

Good! Now all I have to do is declare the variables from the database, then populate the nodes with the <xsl:value-of select="$variablename". Right?As for the program to output, that is already covered in the database program that I am using. When you use the export function to html, you are using an xsl stylesheet to format the output.I will give this a try, and I will be so happy (and so will hundreds of others) if this works.Thank you for the help, and hopefully you will be here for me if anything else comes up.... LOLSandeman
Link to comment
Share on other sites

Good morning all! Okay, lets start off with a bit of code.

<node name="spell">                  <node name="00001">                        <intvalue name="level">0</intvalue>                        <!-- This can be used for spells known -->                        <stringvalue name="name"></stringvalue>                         <!-- This can be used for spells prepared -->                        <intvalue name="prepared">0</intvalue>                        <stringvalue name="shortdescription"></stringvalue>                  </node>                  <node name="00002">                        <intvalue name="level">0</intvalue>                        <stringvalue name="name">Detect Poison</stringvalue>                        <intvalue name="prepared">0</intvalue>                        <stringvalue name="shortdescription">Detects poison in one creature or object.</stringvalue>                  </node>            </node>

This is how the spell entries are shown in the db.xml for the GUI program, I can figure out how to populate the attributes well enough, what I am stuck with is how to show the <node name=”#####”> tag. What needs to happen is the xsl stylesheet needs to count off the spells in the character files and place the information into the respective tags. (With the <xsl:for-each command?) What I can’t figure out is how to make the <node name> attribute to increment by one for each entry. Also, how to make it so it increments like so, 00001, 00002 etc.I have declared a variable,

<xsl:variable name="NODENAMEINCREMENT"  select="" />

where I will put the formula in the select attribute. I am thinkg that you could define another variable, and increment it no? But can you put a variable inside a variable? Any ideas? Sandeman

Link to comment
Share on other sites

Summing the known spells is easy. Just use the sum() function:

<xsl:value-of select="/node/node/sum(@name)" />

However, showing the node's name AND attribute would be a bit more difficult... perhaps variables?

<xsl:variable name="node" select="node/local-name(current())" /><xsl:variable name="attribute-name" select="node/node/local-name(@*) /><xsl:variable name="name" select="node/node/@name" /><{$node} {$attribute-name}="{$name}">whatever</{$node}>

I don't know if this would work... I'll try some other methods, but I think that variables are in some way the answer.

Link to comment
Share on other sites

Summing the known spells is easy. Just use the sum() function:
<xsl:value-of select="/node/node/sum(@name)" />

However, showing the node's name AND attribute would be a bit more difficult... perhaps variables?

<xsl:variable name="node" select="node/local-name(current())" /><xsl:variable name="attribute-name" select="node/node/local-name(@*) /><xsl:variable name="name" select="node/node/@name" /><{$node} {$attribute-name}="{$name}">whatever</{$node}>

I don't know if this would work... I'll try some other methods, but I think that variables are in some way the answer.

Okay, I can see where you are going with this.Here is the amended code from above, using some variables:
<!-- I think that I need to put in a <xsl:for-each command here --> 	 <node name="$NODENAMEINCREMENT" />    <intvalue name="level">   	 <xsl:value-of select="$SPELLLevel" />    </intvalue>    <!-- This can be used for spells known -->    <stringvalue name="name">   	 <xsl:value-of select="$SpellName" />   	 </stringvalue>    <!-- This can be used for spells prepared -->    <intvalue name="prepared">   	 <xsl:value-of select="$SpellPrepared" />    </intvalue>    <stringvalue name="shortdescription">   	 <xsl:value-of select="$SpellShortDescription" />    </stringvalue> 	 </node>

In the db.xml file this format always stays the same, the only difference is the value of $NODENAMEINCREMENT, and the values of each. What this does is put it into a table format that can be dynamically edited by the user. (For instance, the $SpellPrepared will be an integer, that can be updated in the GUI by using the middle mouse wheel. What I am concerned with is the initial value for when the player converts his character over from the database to the program.Now, the part that I am sort of having trouble with is how this is to be [li]repeatedthe node value incremented for each repetitionthe node value incremented in steps of +1 with a starting value of 00001[/li]Nothing too complicated. LOLwould I use the <xsl:for-each> command with the <xsl:test> command to check the database fist, then populate the nodes, then loop this until the spells in the characters files done?Also, how does a person "fix" the value of $NODENAMEINCREMENT to start at "00001" and increment to "00002", "00003" and so on? I can see how to make it "1" and then "2", but the zeroes in front need to be there. Thank you for your help on this.... I am getting closer, I can feel it!Man I love this stuff! <I am such a geek! I love it!>Sandeman

Link to comment
Share on other sites

The way I see it, you've already figured it all (kind'a weird that I'm not sure where are we going :) ). The only thing you need is the format-number() function:

<xsl:value-of select="format-number(current(), 0000#) />

This should output the number before the "," (in our case: the current node) with zeroes and a digit. The zeroes would be replaced by the correct number if the value is higher then 9, so there are no worries here :) .

Link to comment
Share on other sites

The way I see it, you've already figured it all (kind'a weird that I'm not sure where are we going :) ). The only thing you need is the format-number() function:
<xsl:value-of select="format-number(current(), 0000#) />

This should output the number before the "," (in our case: the current node) with zeroes and a digit. The zeroes would be replaced by the correct number if the value is higher then 9, so there are no worries here :) .

Okay, I want to make sure that I have the syntax of this language correct. I have here a code that populates the node attribute for "Feat" with the values returned from the database. The GUI recognises inside the textstring the value /r for a return. (To place the next value on the next line.) I think I have this correct, if so, it would generate the value for the feat attribute of "feat1/rfeat2/rfeat3"... until all feats are listed, then it would end the loop. Do I have this correct?
<xsl:if test="features/feats/feat">	<!-- FEATS -->	<xsl:for-each select="features/feats/feat">  <xsl:variable name="Feat"> 	 <xsl:choose>    <xsl:when test="name = 'Armor Proficiency: heavy' and count(/character/features/class-features/class-feature[feature = 'Heavy armor proficiency'])">   	 <xsl:value-of select="''"/>    </xsl:when>    <xsl:when test="name = 'Armor Proficiency: medium' and count(/character/features/class-features/class-feature[feature = 'Medium armor proficiency'])">   	 <xsl:value-of select="''"/>    </xsl:when>    <xsl:when test="name = 'Armor Proficiency: light' and count(/character/features/class-features/class-feature[feature = 'Light armor proficiency'])">   	 <xsl:value-of select="''"/>    </xsl:when>    <xsl:when test="name = 'Shield Proficiency' and count(/character/features/class-features/class-feature[feature = 'Shield proficiency'])">   	 <xsl:value-of select="''"/>    </xsl:when>    <xsl:when test="name = 'Simple Weapon Proficiency' and count(/character/features/class-features/class-feature[feature = 'Simple weapon proficiency'])">   	 <xsl:value-of select="''"/>    </xsl:when>    <xsl:when test="starts-with(name, 'Martial Weapon Proficiency') and count(/character/features/class-features/class-feature[feature = 'Martial weapon proficiency: all'])">   	 <xsl:value-of select="''"/>    </xsl:when>        <xsl:otherwise>   	 <xsl:value-of select="name"/>    </xsl:otherwise> 	 </xsl:choose>  </xsl:variable> 	 <xsl:choose>    <xsl:when test="position() = 1 and $feat = ''"></xsl:when>    <xsl:when test="position() = 1 and $feat != ''">   	 <xsl:value-of select="$feat"/><xsl:text>/r</xsl:text>    </xsl:when>    <xsl:when test="position() = last() and $feat = ''">    </xsl:when>    <xsl:when test="position() = last() and $feat != ''">   	 <xsl:value-of select="$feat"/><xsl:text>/r</xsl:text>    </xsl:when>    <xsl:when test="$feat = '' and position() != 1 and position() != last()"></xsl:when>    <xsl:otherwise>   	 <xsl:value-of select="$feat"/><xsl:text>/r</xsl:text>    </xsl:otherwise> 	 </xsl:choose>	</xsl:for-each></xsl:if>

SandemanI have learned so much in the last couple of days that my head is swimming!

Link to comment
Share on other sites

I'm not sure I want to know what the output of all this should look like :) .But I do see two small (yet significant) mistakes:1. The name of the variable is Feat and it's callers use $feat instead. That's wrong scince XML is case sencetive. Rename the variable to feat or rename the callers to $Feat.2.

<xsl:value-of select=" ' ' " />

Is that even valid? If you are trying to select the current node, you could use a dot instead:

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

And if you want a space, you can just make a space instead of getting an emty value. An <xsl:value-of /> is suppose to contain an XPath expression or a variable.

Link to comment
Share on other sites

I'm not sure I want to know what the output of all this should look like :) .But I do see two small (yet significant) mistakes:1. The name of the variable is Feat and it's callers use $feat instead. That's wrong scince XML is case sencetive. Rename the variable to feat or rename the callers to $Feat.2.
<xsl:value-of select=" ' ' " />

Is that even valid? If you are trying to select the current node, you could use a dot instead:

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

And if you want a space, you can just make a space instead of getting an emty value. An <xsl:value-of /> is suppose to contain an XPath expression or a variable.

If I remember correctly, the '' is an operator defined in anothe stylesheet that is loaded with the href function, to call the value of the selected entity in the database table. :)As for what it will look like when done:$Feat="armor profiencecy/rdodge/rshot on the run" would be an example.The /r is parsed by the GUI application to be a carriage return or a <p> tag, and will tell the app to place the values on three different lines in the character sheet.Sometimes I get a headache with all of this, as I am dealing with an Access database, xml, xslt and C++ in order to do all of this. But I am learning a lot! LOLSandeman
Link to comment
Share on other sites

Okay, now for some more fun. In dealing with the access database, I need to pull out the values of a table, and make seperate nodes out of all of them.The table has the columns of:NAMETOTAL MODIFIERRANKSTYPEATTRIBUTE BONUSand each is populated with rows of skills.What I am trying to do is this: (In pseudo code..)

Call up the skills table in Etools database            Sort the table in alphabetical order with the Name Column            Select the field with the name of the skill                        Define the name as a variable            Select the Misc modifier field                        Define the misc modifier as a variable            Select the Ranks Modifier Field                        Define the ranks modifier as a variable            Select the Type Field                        Define the type fields as a variable            Select the Total Bonus for the skill field                        Define the total bonus as a variable Repeat this process until all variables are finished Place the attribute values in the appropriate nodes using the variables.             Check to see if the type field is class, cross class or prohibited, place a value depending on what type is.

So, Seeing as how the variables have to be used in the order that they are created, I was looking to split off the variable declarations into another xsl file and call it up using the <import href> command. My reasoning behind this is that all the skills are intermixed with other values in the xml format of the GUI. (Such as hitpoints). By ripping this out into another file, and referencing it, it should work because I am using the variables from that file in order? Now, as for how to select the data in the database. I have this as a start:

<xsl:template match="skill"><!-- <xsl:for-each ….? -- > <xsl:variable name="skillname" select="[@name = 'name']/@value" />  <xsl:variable name="{$skillname}misc"  select="modifiers/modifier[@name = 'misc']/@value" />        <xsl:variable name="{$skillname}ranks"  select="modifiers/modifier[@name = 'rank']/@value" />                  <xsl:variable name="{$skillname}stat"  select="modifiers/modifier[@name = 'ability']/@value" />                  <xsl:variable name="{$skillname}state"  select="modifiers/modifier[@name = 'type']/@value">        <xsl:variable name="{$skillname}total"  select="sum(modifiers/modifier[@name != 'misc']/@value)" /<!-- /xsl:for-each ..  </xsl:template>

Any thoughts? Sandeman

Link to comment
Share on other sites

When variables are imported, they still have some order in the file itself, therefore, the callers would follow the order from within the file.From recent experiments I've done, I know that a variable's name can't refer to another variable, making impossible the thing you want.Another thing I wonder about:

<xsl:variable name="skillname" select="[@name = 'name']/@value" />

I don't think that a path could begin with a predicate. I may be wrong though. Who knows...As for constructing the table... I'm still a bit confused of what is going on, but a table I recently helped with could be found here.Perhaps some adjustment of the XPath expressions might do what you want?

Link to comment
Share on other sites

Consider the following:

<skills>  <skill> 	 <name>Sense Motive</name> 	 <untrained>1</untrained> 	 <ability>Wis</ability> 	 <modifiers>    <modifier name="rank" value="0"/>    <modifier name="ability" value="3"/>    <modifier name="misc" value="0"/> 	 </modifiers> 	 <short-description>Detect when someone is bluffing you, when something is up, or someone is lying. (Wis)</short-description>  </skill>                  .                  .                  .repeat above for each skill           </skills>

This is the xml that I am working with. What I want to do is change it to fill out another xml form. (From the same problem as above) Is this correct?

<xsl:template match="skill">  <!-- Here is where I attempt to get the skills in: -->  [b]<xsl:template match="name" name="Sense Motive"/>[/b]  <xsl:variable name="Sensemotivemisc"  select="modifiers/modifier[@name = 'misc']/@value" /> 	 <intvalue name="sensemotivemisc">    <xsl:value-of select="$Sensemotivemisc"/> 	 </intvalue>  <xsl:variable name="Sensemotiveranks"  select="modifiers/modifier[@name = 'rank']/@value" /> 	 <intvalue name="sensemotiveranks">    <xsl:value-of select="$Sensemotiveranks"/> 	 </intvalue >  <xsl:variable name="Sensemotivestat"  select="modifiers/modifier[@name = 'ability']/@value" /> 	 <intvalue name="sensemotivestat"    <xsl:value-of select="$Sensemotivestat"/> 	 </intvalue>                  </xsl:template>            .             .            .repeat above for each skill       </xsl:template>

What I am trying to do is first: Call the template <skills>, then the template <skill/name>, then I am trying to select the one that says "sense motive", fill in those values, then close the template, repeat the process untill all is done, then close the final template.Am I going about this the right way?Sandeman

Link to comment
Share on other sites

Consider the following:
<skills>  <skill> 	 <name>Sense Motive</name> 	 <untrained>1</untrained> 	 <ability>Wis</ability> 	 <modifiers>    <modifier name="rank" value="0"/>    <modifier name="ability" value="3"/>    <modifier name="misc" value="0"/> 	 </modifiers> 	 <short-description>Detect when someone is bluffing you, when something is up, or someone is lying. (Wis)</short-description>  </skill>                  .                  .                  .repeat above for each skill           </skills>

This is the xml that I am working with. What I want to do is change it to fill out another xml form. (From the same problem as above) Is this correct?

<xsl:template match="skill">  <!-- Here is where I attempt to get the skills in: -->  [b]<xsl:template match="name" name="Sense Motive"/>[/b]  <xsl:variable name="Sensemotivemisc"  select="modifiers/modifier[@name = 'misc']/@value" /> 	 <intvalue name="sensemotivemisc">    <xsl:value-of select="$Sensemotivemisc"/> 	 </intvalue>  <xsl:variable name="Sensemotiveranks"  select="modifiers/modifier[@name = 'rank']/@value" /> 	 <intvalue name="sensemotiveranks">    <xsl:value-of select="$Sensemotiveranks"/> 	 </intvalue >  <xsl:variable name="Sensemotivestat"  select="modifiers/modifier[@name = 'ability']/@value" /> 	 <intvalue name="sensemotivestat"    <xsl:value-of select="$Sensemotivestat"/> 	 </intvalue>                  </xsl:template>            .             .            .repeat above for each skill       </xsl:template>

What I am trying to do is first: Call the template <skills>, then the template <skill/name>, then I am trying to select the one that says "sense motive", fill in those values, then close the template, repeat the process untill all is done, then close the final template.Am I going about this the right way?Sandeman

I was wondering if I can use the xsl command
<xsl:template match="text()"/>

before the

<xsl:template match="name">

to put the priority to the name/nameofskill. The I can proceed naming each, until all are full?Does that make any sense?Sandeman

Link to comment
Share on other sites

As far as I know, nested templates are not allowed. You could use <xsl:call-templates/> element though. Adding attribute "select" would activate the desired template at that spot.I almost see where this is all going. Perhaps the unclear XSLT is the only thing that confuses me now. Here's an altered version of the code:

<xsl:template match="skills"><xsl:for-each select="skill"><xsl:apply-templates select="Sense Motive" /></xsl:for-each>      </xsl:template><xsl:template match="name" name="Sense Motive"/> <xsl:variable name="Sensemotivemisc"  select="modifiers/modifier[@name = 'misc']/@value" />  <intvalue name="sensemotivemisc">   <xsl:value-of select="$Sensemotivemisc"/>  </intvalue> <xsl:variable name="Sensemotiveranks"  select="modifiers/modifier[@name = 'rank']/@value" />  <intvalue name="sensemotiveranks">   <xsl:value-of select="$Sensemotiveranks"/>  </intvalue > <xsl:variable name="Sensemotivestat"  select="modifiers/modifier[@name = 'ability']/@value" />  <intvalue name="sensemotivestat"   <xsl:value-of select="$Sensemotivestat"/>  </intvalue>                 </xsl:template>

I haven't tested it, but if all is correct, it should work.If you want to ensure priority you could use the "priority" attribute of the xsl:template. Just use integer value in it to specify which should have a higher one.

Link to comment
Share on other sites

As far as I know, nested templates are not allowed. You could use <xsl:call-templates/> element though. Adding attribute "select" would activate the desired template at that spot.I almost see where this is all going. Perhaps the unclear XSLT is the only thing that confuses me now. Here's an altered version of the code:
<xsl:template match="skills"><xsl:for-each select="skill"><xsl:apply-templates select="Sense Motive" /></xsl:for-each>     </xsl:template><xsl:template match="name" name="Sense Motive"/><xsl:variable name="Sensemotivemisc"  select="modifiers/modifier[@name = 'misc']/@value" /> <intvalue name="sensemotivemisc">  <xsl:value-of select="$Sensemotivemisc"/> </intvalue><xsl:variable name="Sensemotiveranks"  select="modifiers/modifier[@name = 'rank']/@value" /> <intvalue name="sensemotiveranks">  <xsl:value-of select="$Sensemotiveranks"/> </intvalue ><xsl:variable name="Sensemotivestat"  select="modifiers/modifier[@name = 'ability']/@value" /> <intvalue name="sensemotivestat"  <xsl:value-of select="$Sensemotivestat"/> </intvalue><xsl:template match="name" name="Appraise"/><xsl:variable name="Appraisemisc"  select="modifiers/modifier[@name = 'misc']/@value" /> <intvalue name="appraisemisc">  <xsl:value-of select="$Appraisemisc"/> </intvalue><xsl:variable name="Appraiseranks"  select="modifiers/modifier[@name = 'rank']/@value" /> <intvalue name="appraiseranks">  <xsl:value-of select="$Appraiseranks"/> </intvalue ><xsl:variable name="Appraisestat"  select="modifiers/modifier[@name = 'ability']/@value" /> <intvalue name="appraisestat"  <xsl:value-of select="$Appraisestat"/> </intvalue>                </xsl:template>

Assuming of course you had a node tree for appraise as well..

<skills> <skill>  <name>Sense Motive</name>  <untrained>1</untrained>  <ability>Wis</ability>  <modifiers>   <modifier name="rank" value="0"/>   <modifier name="ability" value="3"/>   <modifier name="misc" value="0"/>  </modifiers>  <short-description>Detect when someone is bluffing you, when something is up, or someone is lying. (Wis)</short-description> </skill> <skill>  <name>Appraise</name>  <untrained>1</untrained>  <ability>Wis</ability>  <modifiers>   <modifier name="rank" value="0"/>   <modifier name="ability" value="3"/>   <modifier name="misc" value="0"/>  </modifiers>  <short-description>You are able to appraise the value of something (Wis)</short-description> </skill>                 .                 .repeat above for each skill          </skills>

Is this looking like it is on the right track?Sandeman

Link to comment
Share on other sites

I added the select attribute to ensure that this would work if there are other things in the XSLT. However, if that's not the case, you can simply remove the select attribute. This would apply ALL templates if only they have appropriate matches inside. This could make the things unstable if not used wisely, but if you have a single XSLT containg only all skills, then you don't need the select attribute and you can remove it without any worries in the short and long term.

Link to comment
Share on other sites

I added the select attribute to ensure that this would work if there are other things in the XSLT. However, if that's not the case, you can simply remove the select attribute. This would apply ALL templates if only they have appropriate matches inside. This could make the things unstable if not used wisely, but if you have a single XSLT containg only all skills, then you don't need the select attribute and you can remove it without any worries in the short and long term.

Okay, so if I am referencing an XML doc with my xslt, the select attribute is selecting only those things within the "skill" node, right?So what I can do is save this off as a skills.xsl sheet, and reference this in the main sheet with <import href="skills.xsl"> command.Is this right?Sandeman
Link to comment
Share on other sites

Okay, so if I am referencing an XML doc with my xslt, the select attribute is selecting only those things within the "skill" node, right?So what I can do is save this off as a skills.xsl sheet, and reference this in the main sheet with <import href="skills.xsl"> command.Is this right?Sandeman

Not quite... It all matters which stylesheet is ran first. That stylesheet imports the rest and all the things inside the included stylesheets are ran if the stylesheet was one and all.That doesn't matter though. The importaint thing here is that:
<xsl:for-each select="skill"><xsl:apply-templates /></xsl:for-each>

Is (as you suggested) going to (try to) apply all other templates at that spot, but technically speaking, if there are no possible relative matches inside, XSLT doesn't have anything to apply the templates on.In short:1st line. Correct2nd line. Wrong

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...