laural Posted April 10, 2014 Posted April 10, 2014 Below I have pasted my XML and below it my XSLT, I am new to XSLT and hope that I am close to fixing my problem. When importing to filemaker, only the first 3 fields are importing, how do I get all of the fields to import? <Meta> <Attribution Url="http://www.this.org">Content provided byThis</Attribution> <ContentType>Article</ContentType> <CopyrightOwner DocID="This Copyright">2ff58aea-95</CopyrightOwner> <DocID>ART-2004</DocID> <UpdateDate>2013-03-27</UpdateDate> <PublicationDate>2013-03-27</PublicationDate> <ControlWords> <Category MCVID="1898" Title="Pregnancy week by week"> <Keyword MCVID="1550" Title="Healthy pregnancy"/> </Category> <Category MCVID="1124" Title="Adult"> <Keyword MCVID="1126" Title="45 to 64 middle"/> </Category> </ControlWords> </Meta> <Body> <Section> <HTML><p> Pregnancy can take a toll on your body. But as much as you need sleep during pregnancy, it doesn't always come easily. Understand how pregnancy affects sleep and what you can do to rest comfortably. </p> </HTML> </Section> <Section> <SectionHead>Why does pregnancy cause fatigue?</SectionHead> <HTML><p> During early pregnancy, levels of the hormone progesterone soar and your metabolism is running high. This can make you feel exhausted. At the same time, lower blood pressure and increased blood production might team up to sap your energy. If you have another child or children to care for, you might experience even more fatigue. </p> <p> While fatigue typically lessens after the first trimester, you'll likely feel tired again toward the end of your pregnancy as your baby increases in size. </p> </HTML> </Section> </Body> <Title>Sleep during pregnancy: Follow these tips</Title> <BenefitSummary>Having a hard time getting sleep during pregnancy? Understand why you're feeling fatigued and strategies for minimizing discomfort and sleep disturbances.</BenefitSummary> <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <ERRORCODE>0</ERRORCODE> <PRODUCT BUILD="" NAME="FileMaker" VERSION="ProAdvanced 12.0v2"/> <DATABASE DATEFORMAT="" LAYOUT="" NAME="" RECORDS="" TIMEFORMAT=""/> <METADATA> <!-- FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Meta" TYPE="TEXT" / --> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="DocID" TYPE="TEXT" /> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="UpdateDate" TYPE="TEXT" /> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="PublicationDate" TYPE="TEXT" /> <!-- FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Section" TYPE="TEXT" / --> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="SectionHead" TYPE="TEXT" /> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="HTML" TYPE="TEXT" /> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Title" TYPE="TEXT" /> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="BenefitSummary" TYPE="TEXT" /> </METADATA> <RESULTSET FOUND=""> <xsl:for-each select="//Meta"> <ROW RECORDID="" MODID="" > <COL><DATA><xsl:value-of select="DocID"/></DATA></COL> <COL><DATA><xsl:value-of select="UpdateDate"/></DATA></COL> <COL><DATA><xsl:value-of select="PublicationDate"/></DATA></COL> </ROW> </xsl:for-each> <xsl:for-each select="//Body/Section"> <ROW RECORDID="" MODID="" > <COL><DATA><xsl:value-of select="SectionHead"/></DATA></COL> <COL><DATA><xsl:value-of select="HTML"/></DATA></COL> </ROW> </xsl:for-each> <xsl:for-each select="Record"> <ROW MODID="" RECORDID=""> <COL><DATA><xsl:value-of select="Title" /></DATA></COL> <COL><DATA><xsl:value-of select="BenefitSummary" /></DATA></COL> </ROW> </xsl:for-each> </RESULTSET> </FMPXMLRESULT> </xsl:template> </xsl:stylesheet>
comment Posted April 10, 2014 Posted April 10, 2014 That's not a valid XML document. Please post a valid (full) XML and indicate what do you want to import.
laural Posted April 11, 2014 Author Posted April 11, 2014 Sorry if my question was not clear. I am not very proficient at creating the XSL doc to complete my import to Filemaker. My question is how do I write my XSL doc to include all of my selects, right now I can get one of the 3 xsl:select for-each statements to import, but not all of them. So that leads me to believe I can only have 1 select for-each statement. If that is the case, how do I indicate where in the hierarchy FM can find the other fields? I hope I am making sense...
comment Posted April 11, 2014 Posted April 11, 2014 There are several problems with your stylesheet. Even the part that does work, works inefficiently. But I cannot fix that without seeing the structure of the source XML document.
laural Posted April 12, 2014 Author Posted April 12, 2014 Here is the XML... I know that my XSL stylesheet is not correct, I have spent a lot of time reading about Filemaker and XML/XSL, but I am having trouble with it, I will continue my research, any insights are appreciated... <Article xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="article.xsd"> <Meta> <Attribution Url="http://www.this.org">Content provided byThis</Attribution> <ContentType>Article</ContentType> <CopyrightOwner DocID="This Copyright">2ff58aea-95</CopyrightOwner> <DocID>ART-2004</DocID> <UpdateDate>2013-03-27</UpdateDate> <PublicationDate>2013-03-27</PublicationDate> <ControlWords> <Category MCVID="1898" Title="Pregnancy week by week"> <Keyword MCVID="1550" Title="Healthy pregnancy"/> </Category> <Category MCVID="1124" Title="Adult"> <Keyword MCVID="1126" Title="45 to 64 middle"/> </Category> </ControlWords> </Meta> <Body> <Section> <HTML><p> Pregnancy can take a toll on your body. But as much as you need sleep during pregnancy, it doesn't always come easily. Understand how pregnancy affects sleep and what you can do to rest comfortably. </p> </HTML> </Section> <Section> <SectionHead>Why does pregnancy cause fatigue?</SectionHead> <HTML><p> During early pregnancy, levels of the hormone progesterone soar and your metabolism is running high. This can make you feel exhausted. At the same time, lower blood pressure and increased blood production might team up to sap your energy. If you have another child or children to care for, you might experience even more fatigue. </p> <p> While fatigue typically lessens after the first trimester, you'll likely feel tired again toward the end of your pregnancy as your baby increases in size. </p> </HTML> </Section> </Body> <Title>Sleep during pregnancy: Follow these tips</Title> <BenefitSummary>Having a hard time getting sleep during pregnancy? Understand why you're feeling fatigued and strategies for minimizing discomfort and sleep disturbances.</BenefitSummary> </Article>
laural Posted April 14, 2014 Author Posted April 14, 2014 I fixed my problem, instead of making separate for-each statements, I just needed to add the path in the value-of select statement - worked like a dream <xsl:for-each select="//Article"> <ROW RECORDID="" MODID="" > <COL><DATA><xsl:value-of select="Title" /></DATA></COL> <COL><DATA><xsl:value-of select="BenefitSummary" /></DATA></COL> <COL><DATA><xsl:value-of select="Meta/DocID" /></DATA></COL> <COL><DATA><xsl:value-of select="Meta/UpdateDate" /></DATA></COL> <COL><DATA><xsl:value-of select="Meta/PublicationDate" /></DATA></COL> <COL><DATA><xsl:value-of select="Body" /></DATA></COL> </ROW> </xsl:for-each>
comment Posted April 21, 2014 Posted April 21, 2014 If (as it seems) the XML document contains only one Article, then you don't need the xsl:for-each statement at all. Note also that unlike all other fields, the expression <xsl:value-of select="Body" /> addresses a complex element. In such case, the expression will return a concatenation of all text nodes that are descendants of <Body>, including whitespace nodes, resulting (using your example above) in: Pregnancy can take a toll on your body. But as much as you need sleep during pregnancy, it doesn't always come easily. Understand how pregnancy affects sleep and what you can do to rest comfortably. Why does pregnancy cause fatigue? During early pregnancy, levels of the hormone progesterone soar and your metabolism is running high. This can make you feel exhausted. At the same time, lower blood pressure and increased blood production might team up to sap your energy. If you have another child or children to care for, you might experience even more fatigue. While fatigue typically lessens after the first trimester, you'll likely feel tired again toward the end of your pregnancy as your baby increases in size. which may not be exactly what you want.
Recommended Posts
This topic is 4135 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now