![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Pattern problem >Thread Next - Re: Pattern problem Re: Pattern problemTo: NULL Date: 8/12/2008 4:02:00 PM
"tshad" <tshad@d...> wrote in message
news:u$Rvt2M$IHA.1180@T......
>
> "tshad" <tshad@d...> wrote in message
> news:%23575tZJ$IHA.5192@T......
>>
>> "tshad" <tfs@d...> wrote in message
>> news:eFEpEnI$IHA.3696@T......
>>>
>>> "Joe Fawcett" <joefawcett@n...> wrote in message
>>> news:%23%23DITRE$IHA.3472@T......
>>>> When you say the name do you mean the formName element, name doesn't
>>>> make sense as the element name is form which you already know?
>>>> <xsl:value-of select="ancestor::form[primary='true']/formName"/>
>>>
>>> Actually, the result I showed that I was looking for, was incorrect.
>>> Sorry.
>>>
>>> What I wanted the last set to look like was:
>>>
>>> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>> <sectionNumber>0</sectionNumber>
>>> <primary>false</primary>
>>> <formName>1004_05</formName> <-------- Want it
>>> to look like this.
>>> <tagName>GR_AGE.1</tagName>
>>> <flags>1</flags>
>>> <format>4096</format>
>>> <value>4 Yrs.</value>
>>> </form>
>>>
>>> and I realize oneof my mistakes was that I don't want "name", but
>>> "@name".
>>>
>>> Would I change you line to:
>>>
>>> <xsl:value-of select="ancestor::form[primary='true']/@name"/>
>
> I also tried:
>
> <xsl:value-of select="preceding::form[primary='true']/@name"/>
>
> and
>
> <xsl:value-of select="preceding-sibling::form[primary='true']/@name"/>
>
> and the VS 2005 QuickWatch shows the result as {Dimension:[0]}. Not sure
> what that means but I assume it means it found nothing.
ancestor::form/@name gives me 1007, as it should. But I need to look at all
the forms on the same level and get the one that has @primary = 'true' and
use the @name of that form.
Is this the wrong way to get that?
Seems pretty straight forward.
I assume the pattern in:
<xsl:value-of select="ancestor::form[@primary='true']/@name"/>
says to look for all the ancestor "form" tags and look at the one that one.
I did notice that I had primary set in my program without the "@". But even
after changing it to the above is not working.
Thanks,
Tom
>
> Tom
>
>>>
>>>>
>>
>> That doesn't seem to work either.
>>
>> I changed the "choose" section of the <formName> part to:
>>
>> <formName>
>> <xsl:choose>
>> <xsl:when test="ancestor::form/@name = '1007'">
>> <xsl:value-of select="ancestor::form[primary='true']/@name"/>
>> </xsl:when>
>> <xsl:otherwise>
>> <xsl:value-of select="ancestor::form/@name"/>
>> </xsl:otherwise>
>> </xsl:choose>
>> </formName>
>>
>> but I am still getting
>>
>> <formName></formName>
>>
>> Tom
>>>> "I was just guessing on this statement and not sure how to get it to
>>>> work"
>>>> You're not going to get far in XSLT like this, get a good reference
>>>> such as Michael Kay's latest tome from Wrox, XSLT 4th Edition.
>>>
>>> I will.
>>>
>>> I only have the O'Reilly book (Learning XSLT).
>>>
>>> Thanks,
>>>
>>> Tom
>>>>
>>>> --
>>>>
>>>> Joe Fawcett (MVP - XML)
>>>> http://joe.fawcett.name
>>>>
>>>>
>>>>
>>>>
>>>> "tshad" <tshad@d...> wrote in message
>>>> news:eByPhqB$IHA.1036@T......
>>>>> I can't seem to get this pattern to work:
>>>>>
>>>>> I have stripped down my files for testing:
>>>>>
>>>>> In a nutshell, what I am trying to do is this:
>>>>>
>>>>> <xsl:when test="ancestor::form/@name = '1007'">
>>>>> <xsl:value-of select="name[ancestor::form/primary='true']"/>
>>>>> </xsl:when>
>>>>>
>>>>> If the form/@name = '1007', I want to go look at the other form tags
>>>>> to find the one that has an attribute primary='true' and use that name
>>>>> for my form name. But I am getting a blank entry. I was just
>>>>> guessing on this statement and not sure how to get it to work:
>>>>>
>>>>> My xslt file:
>>>>> *****************************************************
>>>>> <xsl:stylesheet version="1.0"
>>>>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>>>> <xsl:output method="xml" indent="yes"/>
>>>>> <xsl:template match="/*">
>>>>> <xsl:copy>
>>>>> <xsl:apply-templates select="appraisal/data/form/tag |
>>>>> appraisal/data/form/section/tag">
>>>>> <xsl:sort select="ancestor::form/@primary" order="descending"/>
>>>>> <xsl:sort select="ancestor::section/@number" order="ascending"
>>>>> data-type="number"/>
>>>>> </xsl:apply-templates>
>>>>> </xsl:copy>
>>>>> </xsl:template>
>>>>> <xsl:template match="tag">
>>>>> <form>
>>>>> <sectionNumber>
>>>>> <xsl:value-of select="ancestor::section/@number"/>
>>>>> </sectionNumber>
>>>>> <primary>
>>>>> <xsl:value-of select="ancestor::form/@primary"/>
>>>>> </primary>
>>>>> <formName>
>>>>> <xsl:choose>
>>>>> <xsl:when test="ancestor::form/@name = '1007'">
>>>>> <xsl:value-of select="name[ancestor::form/primary='true']"/>
>>>>> <---------
>>>>> </xsl:when>
>>>>> <xsl:otherwise>
>>>>> <xsl:value-of select="ancestor::form/@name"/>
>>>>> </xsl:otherwise>
>>>>> </xsl:choose>
>>>>> </formName>
>>>>> <tagName>
>>>>> <xsl:value-of select="@name"/>
>>>>> </tagName>
>>>>> <flags>
>>>>> <xsl:if test="not(@flags)">
>>>>> <xsl:attribute name="xsi:nil">true</xsl:attribute>
>>>>> </xsl:if>
>>>>> <xsl:value-of select="@flags"/>
>>>>> </flags>
>>>>> <format>
>>>>> <xsl:if test="not(@format)">
>>>>> <xsl:attribute name="xsi:nil">true</xsl:attribute>
>>>>> </xsl:if>
>>>>> <xsl:value-of select="@format"/>
>>>>> </format>
>>>>> <value>
>>>>> <xsl:value-of select="text()"/>
>>>>> </value>
>>>>> </form>
>>>>> <xsl:apply-templates select="addendum[heading | body]"/>
>>>>> </xsl:template>
>>>>> </xsl:stylesheet>
>>>>> ******************************************************
>>>>>
>>>>> My xml file:
>>>>> ******************************************************
>>>>> <?xml version="1.0" encoding="utf-8"?>
>>>>> <Report>
>>>>> <appraisal>
>>>>> <data>
>>>>> <form name="1007" primary="false">
>>>>> <section type="subject" number="0">
>>>>> <tag name="GR_AGE.1" flags="1" format="4096">4 Yrs.</tag>
>>>>> </section>
>>>>> </form>
>>>>> <form name="reffee" primary="false">
>>>>> <tag name="FFHD_NFIP_COMMUNITY_NUMBER.1" flags="0"
>>>>> format="0">040040</tag>
>>>>> </form>
>>>>> <form name="1004_05" primary="true">
>>>>> <section type="subject" number="0">
>>>>> <tag name="PROP_PHYS_DEFICIENCIES_DESC.1" flags="4"
>>>>> format="4096">None apparent </tag>
>>>>> </section>
>>>>> </form>
>>>>> </data>
>>>>> </appraisal>
>>>>> </Report>
>>>>> ********************************************************
>>>>>
>>>>> My result:
>>>>> ******************************************************
>>>>> <?xml version="1.0" encoding="utf-8"?>
>>>>> <Report>
>>>>> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>>>> <sectionNumber>0</sectionNumber>
>>>>> <primary>true</primary>
>>>>> <formName>1004_05</formName>
>>>>> <tagName>PROP_PHYS_DEFICIENCIES_DESC.1</tagName>
>>>>> <flags>4</flags>
>>>>> <format>4096</format>
>>>>> <value>None apparent </value>
>>>>> </form>
>>>>> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>>>> <sectionNumber></sectionNumber>
>>>>> <primary>false</primary>
>>>>> <formName>reffee</formName>
>>>>> <tagName>FFHD_NFIP_COMMUNITY_NUMBER.1</tagName>
>>>>> <flags>0</flags>
>>>>> <format>0</format>
>>>>> <value>040040</value>
>>>>> </form>
>>>>> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>>>> <sectionNumber>0</sectionNumber>
>>>>> <primary>false</primary>
>>>>> <formName></formName> <-------- Want this to
>>>>> be 1004_05
>>>>> <tagName>GR_AGE.1</tagName>
>>>>> <flags>1</flags>
>>>>> <format>4096</format>
>>>>> <value>4 Yrs.</value>
>>>>> </form>
>>>>> </Report>
>>>>> *******************************************************
>>>>>
>>>>> Everything else works fine.
>>>>>
>>>>> What should that line be? Do I need to do another match and template?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Tom
>>>>>
>>>
>>>
>>
>>
>
>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
